测试同学跑Monkey跑出了这个异常导致的crash,对应的Android版本是Android6.0。
补充:出问题的Activity是使用了ViewPager无限循环展示图片,内容是ImageView,不是Fragment。
但是我的应用中没有用到任何Fragment,任何commit方法。详细Log如下:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1438) at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:581) at android.app.Activity.onBackPressed(Activity.java:2537) at android.app.Activity.onKeyUp(Activity.java:2511) at android.view.KeyEvent.dispatch(KeyEvent.java:2695) at android.app.Activity.dispatchKeyEvent(Activity.java:2764) at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2384) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4687) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4643) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4155) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4208) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4174) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4320) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4182) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4377) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4155) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4208) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4174) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4182) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4155) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4208) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4174) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4353) at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4523) at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2336) at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1940) at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1931) at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2313) at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:328) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:5811) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
在StackOverFlow上搜到了类似的问题:http://stackoverflow.com/ques...
StackOverFlow上说要重写onSaveInstaceState方法,去掉super调用,但是我不清楚这样做是否存在负作用,所以希望有经验的人指导一下如何解决这个问题。
方案二(参考StackOverFlow上的做法)——重写onSaveInstanceState方法:
一周热门 更多>