解决java.lang.IllegalStateException: Can not perform this action after onSaveInstance

commit

added in API level 11
int commit ()

Schedules a commit of this transaction. The commit does not happen immediately; it will be scheduled as work on the main thread to be done the next time that thread is ready.

A transaction can only be committed with this method prior to its containing activity saving its state. If the commit is attempted after that point, an exception will be thrown. This is because the state after the commit can be lost if the activity needs to be restored from its state. See commitAllowingStateLoss() for situations where it may be okay to lose the commit.

commitAllowingStateLoss

added in API level 11
int commitAllowingStateLoss ()

Like commit() but allows the commit to be executed after an activity's state is saved. This is dangerous because the commit can be lost if the activity needs to later be restored from its state, so this should only be used for cases where it is okay for the UI state to change unexpectedly on the user.



getDialogFragment().dismissAllowingStateLoss();





https://blog.csdn.net/gaojiaxingde/article/details/32709401

https://blog.csdn.net/ranxiedao/article/details/8214936

猜你喜欢

转载自blog.csdn.net/jingwen3699/article/details/80240120