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

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

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

@Override
public void onBackPressed() {
    Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_HOME);
    startActivity(i);
}

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

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
   at android.os.Parcel.readException(Parcel.java:1425)
   at android.os.Parcel.readException(Parcel.java:1379)
   at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1761)
   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1411)
   at android.app.Activity.startActivityForResult(Activity.java:3351)
   at android.app.Activity.startActivityForResult(Activity.java:3312)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
   at android.app.Activity.startActivity(Activity.java:3522)
   at android.app.Activity.startActivity(Activity.java:3490)
   at itpp.anubhabmassretail.MainActivity.onBackPressed(MainActivity.java:87)
   at android.app.Activity.onKeyUp(Activity.java:2131)
   at android.view.KeyEvent.dispatch(KeyEvent.java:2633)
   at android.app.Activity.dispatchKeyEvent(Activity.java:2361)
   at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchKeyEvent(ActionBarActivityDelegateICS.java:258)
   at    com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1823)
   at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3600)
   at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3570)
   at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2809)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4794)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
   at dalvik.system.NativeStart.main(NativeStart.java)
ozxc1zmp

ozxc1zmp1#

添加

android:exported="true"

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

m4pnthwp

m4pnthwp2#

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

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

相关问题