首页 > 代码库 > 解决Can not perform this action after onSaveInstanceState

解决Can not perform this action after onSaveInstanceState

以下为错误日志--------start--------

01-08 23:43:19.622: E/AndroidRuntime(961): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=http://www.mamicode.com/Intent { }} to activity {com.biggod/com.biggod.activity.MainActivity}: java.lang.IllegalStateException: Can>


end-------------------------

遇到这个问题是我在onActivityResult方法中,执行以下语句

getSupportFragmentManager().beginTransaction().replace(R.id.fragment_contiainer,new OwnFragment()).commit();


OwnFragment是我自己写的fragment。我是为了重新刷新界面而执行该语句。就出现了上述错误。

解决方法:

将commit()方法,替换为

commitAllowingStateLoss();

即:

getSupportFragmentManager().beginTransaction().replace(R.id.fragment_contiainer,new OwnFragment()).commitAllowingStateLoss();

即可解决问题。


解决Can not perform this action after onSaveInstanceState