P
P
penexe2016-02-03 13:13:59
Android
penexe, 2016-02-03 13:13:59

Problem with arrow in toolbar, Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState?

I create an activity, from this activity I create the same one but with a different parameter. If you click on the arrow in the toolbar on the 2nd activity, it will close, if you click again next, nothing will happen

@Override
    public void onClickDrawerNavigation() {
        NewsActivity.this.finish();
    }

if you replace it NewsActivity.this.finish();with onBackPressed();
something after the 2nd click, a crash occurs
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1489)
       at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:584)
       at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:169)
       at ru.cl.cl.NewsActivity.onBackPressed(NewsActivity.java:163)
       at ru.cl.cl.NewsActivity.onClickDrawerNavigation(NewsActivity.java:171)
       at ru.cl.cl.DrawerMenu$1.onNavigationClickListener(DrawerMenu.java:87)
       at com.mikepenz.materialdrawer.DrawerBuilder$1.onClick(DrawerBuilder.java:1327)
       at android.view.View.performClick(View.java:5181)
       at android.view.View$PerformClick.run(View.java:20887)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5942)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

the first activity is created from a fragment
. And if you press the hard button, then all activities are closed correctly in both options.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question