“Can not perform this action after onSaveInstanceState” with Fragment

故事扮演 提交于 2020-01-06 06:24:11

问题


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

I check the connected Internet and if it false, then call method openAsRoot in onCreate() Activity

private void openAsRoot(Fragment fragment) {
    manager = getSupportFragmentManager();
    manager.beginTransaction()
            .replace(R.id.container_main, fragment).commit();
}

it is perfect, but when I open the settings to turn on the Internet and then go back to my application - showed error in

    @Override
protected void onRestart() {
    if (isConnected()) {
        openAsRoot(myFragment);
    }
    super.onRestart();
}

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

How can I fix this ?

来源:https://stackoverflow.com/questions/48690574/can-not-perform-this-action-after-onsaveinstancestate-with-fragment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!