Fragment异常:Can not perform this action after onSaveInstanceState
2017-08-01 09:51
453 查看
原因:在你离开当前Activity等情况下,系统会调用onSaveInstanceState()帮你保存当前Activity的状态、数据等,直到再回到该Activity之前(onResume()之前),你执行Fragment事务,就会抛出该异常!
解决方法:
1、使用commitAllowingStateLoss()方法提交。但是有可能导致该次提交无效.
2、在重新回到该Activity的时候(onResumeFragments()或onPostResume()),再执行该事务.
support-26.0.0开始,Fragment以及FragmentManager提供了isStateSaved(),可以判断宿主是否已经执行过onSaveInstanceState()
解决方法:
1、使用commitAllowingStateLoss()方法提交。但是有可能导致该次提交无效.
2、在重新回到该Activity的时候(onResumeFragments()或onPostResume()),再执行该事务.
support-26.0.0开始,Fragment以及FragmentManager提供了isStateSaved(),可以判断宿主是否已经执行过onSaveInstanceState()
相关文章推荐
- Android Fragment State Saving. 以及 Can not perform this action after onSaveInstanceState 异常.
- Can not perform this action after onSaveInstanceState(fragment异常)
- Fragment提交commit时候异常(Can not perform this action after onSaveInstanceState)
- fragment 异常IllegalStateException: Can not perform this action after onSaveInstanceState
- 使用自定义DialogFragment出现IllegalStateException: Can not perform this action after onSaveInstanceState异常
- fragment/dialogfragment异常:Can not perform this action after onSaveInstanceState
- DialogFragment show()如何防止Can not perform this action after onSaveInstanceState
- Fragment中出现Can not perform this action after onSaveInstanceState
- 解决异常IllegalStateException: Can not perform this action after onSaveInstanceState
- Fragment的展现与Activity状态丢失 IllegalStateException:Can not perform this action after onSaveInstanceState
- Fragment 出现Can not perform this action after onSaveInstanceState
- 解决Fragment IllegalStateException: Can not perform this action after onSaveInstanceState
- Fragment错误:IllegalStateException: Can not perform this action after onSaveInstanceState
- Fragment Can not perform this action after onSaveInstanceState
- Fragment Or DialogFragment Can not perform this action after onSaveInstanceState
- 今天使用Fragment的时候,出现了这个错误 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
- Fragment java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- DialogFragment - Can not perform this action after onSaveInstanceState