0

我正在创建从 Android 菜单列表中隐藏应用程序的应用程序。我正在使用以下代码来隐藏应用程序。

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(
                    "package name", "class name");
p.setComponentEnabledSetting(getComponentName(),
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);

疑点:

  • 如果我想隐藏应用程序,那么我要求我的 android 手机已植根是否正确?

问题

  • 我的应用程序中有两个活动。第一个活动仅显示按钮,单击后进入第二个活动。我在第二个活动中写了上面的代码。在执行上述代码的第二个活动时,没有向我显示任何错误消息。但是当我再次运行我的应用程序时,它会在从第一个活动移动到第二个活动时显示错误(即在 Intent 中)。

这是我的意图代码:

Intent intent = new Intent(getApplicationContext(),
                    DisplayApplication.class);
intent.putExtra("Pass", "P");
startActivity(intent);

LogCat 输出

11-15 14:15:45.368: E/AndroidRuntime(2707): FATAL EXCEPTION: main
11-15 14:15:45.368: E/AndroidRuntime(2707): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.lockscreenpattern/com.example.lockscreenpattern.DisplayApplication}; have you declared this activity in your AndroidManifest.xml?
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.app.Activity.startActivityForResult(Activity.java:2827)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.app.Activity.startActivity(Activity.java:2933)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at com.example.lockscreenpattern.MainActivity.onClick(MainActivity.java:124)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.view.View.performClick(View.java:2485)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.view.View$PerformClick.run(View.java:9080)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.os.Handler.handleCallback(Handler.java:587)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.os.Looper.loop(Looper.java:130)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at android.app.ActivityThread.main(ActivityThread.java:3687)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at java.lang.reflect.Method.invokeNative(Native Method)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at java.lang.reflect.Method.invoke(Method.java:507)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
11-15 14:15:45.368: E/AndroidRuntime(2707):     at dalvik.system.NativeStart.main(Native Method)
4

0 回答 0