SecurityException:权限拒绝:启动Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME]

ippsafx7  于 2023-06-20  发布在  Android
关注(0)|答案(2)|浏览(165)

在我的应用程序中,当用户按回应用程序是最小化。这就是onBackPressed()方法

  1. @Override
  2. public void onBackPressed() {
  3. Intent i = new Intent();
  4. i.setAction(Intent.ACTION_MAIN);
  5. i.addCategory(Intent.CATEGORY_HOME);
  6. startActivity(i);
  7. }

但是它显示了这个错误,我不知道如何解决它。请帮我一下。
这是错误日志

  1. java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=com.android.customlockapp/.CustomLockLauncher } from ProcessRecord{41490d70 456:itpp.anubhabmassretail/u0a100} (pid=456, uid=10100) not exported from uid 10061
  2. at android.os.Parcel.readException(Parcel.java:1425)
  3. at android.os.Parcel.readException(Parcel.java:1379)
  4. at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1761)
  5. at android.app.Instrumentation.execStartActivity(Instrumentation.java:1411)
  6. at android.app.Activity.startActivityForResult(Activity.java:3351)
  7. at android.app.Activity.startActivityForResult(Activity.java:3312)
  8. at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
  9. at android.app.Activity.startActivity(Activity.java:3522)
  10. at android.app.Activity.startActivity(Activity.java:3490)
  11. at itpp.anubhabmassretail.MainActivity.onBackPressed(MainActivity.java:87)
  12. at android.app.Activity.onKeyUp(Activity.java:2131)
  13. at android.view.KeyEvent.dispatch(KeyEvent.java:2633)
  14. at android.app.Activity.dispatchKeyEvent(Activity.java:2361)
  15. at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchKeyEvent(ActionBarActivityDelegateICS.java:258)
  16. at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1823)
  17. at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3600)
  18. at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3570)
  19. at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2809)
  20. at android.os.Handler.dispatchMessage(Handler.java:99)
  21. at android.os.Looper.loop(Looper.java:137)
  22. at android.app.ActivityThread.main(ActivityThread.java:4794)
  23. at java.lang.reflect.Method.invokeNative(Method.java)
  24. at java.lang.reflect.Method.invoke(Method.java:511)
  25. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
  26. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
  27. at dalvik.system.NativeStart.main(NativeStart.java)
ozxc1zmp

ozxc1zmp1#

添加

  1. android:exported="true"

你的活动清单
(有点迟来的答案,但…still:D)

m4pnthwp

m4pnthwp2#

在MainActivity.cs中,我添加了'Exported = true'

  1. [Activity(WindowSoftInputMode = SoftInput.AdjustResize,
  2. HardwareAccelerated = true, ResizeableActivity = false,Exported = true)]

相关问题