Can not perform this action after onSaveInstanceState

ententjava.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
	android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1500)
	android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1518)
	android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)

出现这个错误主要是由于依赖的Activity或者Fragment生命周期处理不当导致的。

最简单的解决方式就是:

FragmentTransaction ft = manager.beginTransaction();
ft.add(this, getClass().getSimpleName());
ft.commitAllowingStateLoss(); //这里使用当前api代替:ft.commit()

2 评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注