調用 dialog.show(getSupportFragmentManager(), "tag");時出現了java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState的錯誤。
報錯的原因:dialog.show()方法的內部使用了commit()方法提交事務,某些時候因為狀態異常而報錯。解決方法就是使用commitAllowingStateLoss()方法,具體如下所示:
解決方法:不調用dialog.show()方法,而是調用getSupportFragmentManager().beginTransaction().add(dialog, "tag").commitAllowingStateLoss();