IllegalStateException - 在stacktrace中没有对我的代码的引用

时间:2014-02-10 06:35:03

标签: android illegalstateexception android-appcompat

此stacktrace已提交给我的项目问题跟踪器。 因为你没有引用我的代码,所以有人知道如何修复它吗? 我正在使用支持库v19.0.1,如果需要,我可以提供有关设备/平台的更多详细信息


java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
        at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:486)
        at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:179)
        at android.support.v7.app.ActionBarActivity.onBackPressed(ActionBarActivity.java:250)
        at android.app.Activity.onKeyUp(Activity.java:2099)
        at android.view.KeyEvent.dispatch(KeyEvent.java:2575)
        at android.app.Activity.dispatchKeyEvent(Activity.java:2329)
        at android.support.v7.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchKeyEvent(ActionBarActivityDelegateICS.java:250)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1806)
        at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3344)
        at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3317)
        at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2464)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

我做的第一个改变是

 getSupportFragmentManager().beginTransaction()
.add(R.id.container,new CatListFragment(null)).commitAllowingStateLoss();

第二个更改是截取onPause onStop和onResume用于活动,如果应用程序处于暂停状态(或任何其他方式),则保持标志。意图不是在暂停状态下调用.commit()或.commitAllowingStateLoss()。恢复应用后,您可以调用FragmentManager提交。为我工作:))