bug java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

在有Fragment的Activity中开启Activity出现下面这个Exception:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1354)
at android.support.v4.app.BackStackRecord.com

......

 

这个exception的解决方法

1、重写onSaveInstanceState方法不,不执行 super.onSaveInstanceState(outState);

@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
// super.onSaveInstanceState(outState);
}

 

2、启动activity的时候放在hander.post(runnable)的 runnable 中执行

 

posted @ 2015-05-07 17:30  逊志  阅读(176)  评论(0编辑  收藏  举报