gpt4 book ai didi

android - IllegalStateException 设置后无法更改 Activity 类型

转载 作者:行者123 更新时间:2023-12-03 13:24:52 26 4
gpt4 key购买 nike

我可以看到在多个设备上引发了一个异常,除了使用该异常字符串的 Google 测试类之外,我找不到任何东西。
你有什么暗示为什么会发生这种情况吗?

Fatal Exception: java.lang.IllegalStateException: Can't change activity type once set: { mBounds=Rect(0, 0 - 1080, 2076) mAppBounds=Rect(0, 0 - 1080, 2076) mWindowingMode=fullscreen mActivityType=home} activityType=standard
at android.os.Parcel.createException(Parcel.java:1974)
at android.os.Parcel.readException(Parcel.java:1934)
at android.os.Parcel.readException(Parcel.java:1884)
at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:3604)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1669)
at android.app.Activity.startActivityForResult(Activity.java:4688)
at android.support.v4.app.FragmentActivity.startActivityForResult(SourceFile:767)
at android.app.Activity.startActivityForResult(Activity.java:4646)
at android.support.v4.app.FragmentActivity.startActivityForResult(SourceFile:754)
at android.app.Activity.startActivity(Activity.java:5007)
at android.app.Activity.startActivity(Activity.java:4975)
at com.myapp.MyActivity.showAndroidHomeScreen(SourceFile:208)
at com.myapp.MyActivity.onBackPressed(SourceFile:548)
at android.app.Activity.onKeyUp(Activity.java:3168)
at android.view.KeyEvent.dispatch(KeyEvent.java:3374)
at android.app.Activity.dispatchKeyEvent(Activity.java:3451)
at android.support.v4.app.SupportActivity.superDispatchKeyEvent(SourceFile:108)
at android.support.v4.view.KeyEventDispatcher.dispatchKeyEvent(SourceFile:84)
at android.support.v4.app.SupportActivity.dispatchKeyEvent(SourceFile:126)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(SourceFile:535)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(SourceFile:59)
at android.support.v7.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(SourceFile:2533)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:564)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:6012)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5867)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5320)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5373)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5339)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5498)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5347)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5555)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5320)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5373)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5339)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5347)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5320)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5373)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5339)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5531)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5700)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:3407)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2854)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2845)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:3384)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:181)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

Caused by android.os.RemoteException: Remote stack trace:
at android.app.WindowConfiguration.setActivityType(WindowConfiguration.java:366)
at android.app.WindowConfiguration.setTo(WindowConfiguration.java:390)
at android.content.res.Configuration.setTo(Configuration.java:1136)
at com.android.server.wm.ConfigurationContainer.onConfigurationChanged(ConfigurationContainer.java:124)
at com.android.server.wm.ConfigurationContainer.onParentChanged(ConfigurationContainer.java:523)

这是导致问题的代码:
 private void showAndroidHomeScreen() {
final Intent mainScreen = new Intent(Intent.ACTION_MAIN);
mainScreen.addCategory(Intent.CATEGORY_HOME);
mainScreen.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
PackageManager pm = getPackageManager();
if (pm.queryIntentActivities(mainScreen, 0).size() > 0) {
startActivity(mainScreen);
}
}

最佳答案

是启动器问题。只需检查不同的启动器
根本原因它正在发生,因为启动器正在使用 launchMode="singleInstance"作为它的启动器 Activity 。如果它是您的启动器,则使用 android:launchMode="singleTask"。
也尝试删除

mainScreen.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)


希望能帮助到你。
更新
更新了 android:launchMode="singleTask"的 Activity ,您需要设置为默认值,它将解决您的问题。
无需使用 FLAG_ACTIVITY_NO_HISTORY。

关于android - IllegalStateException 设置后无法更改 Activity 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55005798/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com