java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState 异常解决方案
2018-01-29 15:22
513 查看
异常情景
最近在更改项目需求的时候,有在下个界面(以下统称B界面)改变状态之后,上个界面
(以下统称A界面)的状态也需要重新加载一下数据,于是就在打开下个界面某个状态改变之后,上个界面的数据重新请求加载一下,逻辑写完之后,在7.0测试机上面没人任何问题,然后在5.0手机上面测试的时候就出现了上诉异常:
查明原因
最后通过打印生命周期日志的方式,排查到问题所在,在5.0手机上面,打开下一个界面时,上个界面执行了onSaveInstanceState()方法,然后A界面在执行fragment提交事务commit()操作时便会出现异常,然后在在而在7.0手机上面没有执行onSaveInstanceState()方法,所以在5.0手机上面就会出现异常情况。
解决方式
可以通过两种方式进行解决:1、使用FragmentTransaction.commitAllowingStateLoss来提交事务。
2、重写onSaveInstanceState方法,然后不去调用
super.onSaveInstanceState(outState)方法。
相关文章推荐
- java.lang.IllegalStateException Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState的解决方法
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- STACK_TRACE=java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after on SaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决
- Fragment java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- Android 异常java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- java.lang.IllegalStateException: Can not perform this action after onSaveInstance
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- 解决Fragment IllegalStateException: Can not perform this action after onSaveInstanceState