html
commit()方法不能在onSaveInstanceState方法後調用 不然發生崩潰詳情請看 http://www.cnblogs.com/kissazi2/p/4181093.htmlFragment的中commitAllowStateLoss()和commit()之間的區別java
若是使用commitAllowStateLoss()方法;能夠解決崩潰問題,android
若是使用commit()方法 當生命週期方法的onSaveInstanceState()執行事後,會發生崩潰日誌以下:app
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1341) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1352) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)this