android - After Activity is destroyed: Can not perform this action after onSaveInstanceState -
i receiving exception , can't figure out why:
can not perform action after onsaveinstancestate.
this how i'm adding first fragment when activity inside oncreate():
new handler().post(new runnable() { public void run() { final fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmentmanager .begintransaction() .add(id, fragment) .commit(); } }); inside first fragment have button leads fragment. navigate fragment this:
new handler().post(new runnable() { public void run() { final fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmentmanager .begintransaction() .addtobackstack(fragment.getclass().getname()) .add(id, fragment) .commit(); } }); first time when open app, initial fragment shows , can navigate fragment without problem. can navigate first fragment calling popbackstack() or onbackpressed() on activity. navigation works no matter how many times go , forth.
the problem occurs if open app first time, initial fragment appears , click button closes app. in case, when open app second time , click on button leads fragment, i'm getting exception.
any suggestions?
add ur activity. hope solves
@override public void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); if (outstate.isempty()) { outstate.putboolean("bug:fix", true); } }
Comments
Post a Comment