code:

            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            startActivity(intent);

error:

E/MessageQueue-JNI: java.lang.IllegalStateException: Can't change activity type once set: { mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 88 - 1080, 2265) mMaxBounds=Rect(0, 0 - 1080, 2400) mWindowingMode=fullscreen mDisplayWindowingMode=undefined mActivityType=home mAlwaysOnTop=undefined mRotation=undefined mPopOver=off mFreeformTaskPinningState=undefined} activityType=standard
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2446)
        at android.os.Parcel.createException(Parcel.java:2422)
        at android.os.Parcel.readException(Parcel.java:2405)
        at android.os.Parcel.readException(Parcel.java:2347)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2897)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1743)
        at android.app.Activity.startActivityForResult(Activity.java:5473)
        at android.app.Activity.startActivityForResult(Activity.java:5431)
        at android.app.Activity.startActivity(Activity.java:5817)
        at android.app.Activity.startActivity(Activity.java:5770)
        at com.opendemo.test.MainActivity.onKeyDown(:1)
        at android.view.KeyEvent.dispatch(KeyEvent.java:3664)
        at android.app.Activity.dispatchKeyEvent(Activity.java:4230)
        at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:823)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:7727)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7550)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6927)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6984)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6950)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7148)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6958)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7205)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6931)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6984)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6950)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6958)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6931)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6984)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6950)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7181)
        at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:7368)
        at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:3411)
        at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2972)
        at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2963)
        at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:3388)
        at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:154)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:335)
        at android.os.Looper.loopOnce(Looper.java:186)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8751)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
     Caused by: android.os.RemoteException: Remote stack trace:
        at android.app.WindowConfiguration.setActivityType(WindowConfiguration.java:534)
        at android.app.WindowConfiguration.setTo(WindowConfiguration.java:549)
        at android.content.res.Configuration.setTo(Configuration.java:1319)
        at com.android.server.wm.ConfigurationContainer.onConfigurationChanged(ConfigurationContainer.java:137)

I have tried to add permission {"delegatedScopes": ["PACKAGE_ACCESS","ENABLE_SYSTEM_APP"]} in the application configuration, but it did not produce any effect, now do not know how to do, hope to get relevant solutions or ideas, thanks.

1

There are 1 answers

0
JT W On BEST ANSWER

I have fixed this problem, it is very simple to do, just add a configuration can be solved, I do not know whether it will help you.

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);