猿问

IllegalStateException:在使用ViewPager的onSaveInstance

IllegalStateException:在使用ViewPager的onSaveInstanceState之后无法执行此操作

我在市场上从我的应用程序中得到用户报告,提供了以下例外:


java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1109)

at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:399)

at android.app.Activity.onBackPressed(Activity.java:2066)

at android.app.Activity.onKeyUp(Activity.java:2044)

at android.view.KeyEvent.dispatch(KeyEvent.java:2529)

at android.app.Activity.dispatchKeyEvent(Activity.java:2274)

at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1803)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1855)

at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1277)

at android.app.Activity.dispatchKeyEvent(Activity.java:2269)

at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1803)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.widget.TabHost.dispatchKeyEvent(TabHost.java:297)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)

显然,这与FragmentManager有关,我不使用它。堆栈跟踪没有显示任何我自己的类,所以我不知道这个异常发生在哪里,也不知道如何防止它。


记录在案:我有一个表主机,在每个选项卡中都有一个ActivityGroup在活动之间切换。


动漫人物
浏览 382回答 3
3回答

慕标琳琳

请核对我的答案这里..基本上我只需要:@Overrideprotected void onSaveInstanceState(Bundle outState) {     //No call for super(). Bug on API Level > 11.}不要打电话到super()在saveInstanceState方法。这件事搞砸了.。这是一个已知的虫虫在一揽子支援计划中。如果您需要保存实例并向您的outState Bundle您可以使用以下内容:@Overrideprotected void onSaveInstanceState(Bundle outState) {     outState.putString("WORKAROUND_FOR_BUG_19917_KEY", "WORKAROUND_FOR_BUG_19917_VALUE");     super.onSaveInstanceState(outState);}最后,适当的解决办法是(如评论中所示)使用:transaction.commitAllowingStateLoss();添加或执行FragmentTransaction导致Exception.
随时随地看视频慕课网APP

相关分类

Android
我要回答