Illegalstateexception:can not perform this action after Onsaveinstancestate
This address: Http://blog.csdn.net/caroline_wendy
Reference: http://stackoverflow.com/questions/7469082/ getting-exception-illegalstateexception-can-not-perform-this-action-after-onsa/10261438#10261438
Explanation:The most stupid bug I has encountered so far. I had a Fragment application working perfectly for API < One, and force Closing on API > one.I really couldn ' t figure out which they changed inside the Activity lifecycle in the call to Saveinstance, but I am here I S-I solved this:
@Overrideprotected void Onsaveinstancestate (Bundle outstate) { //no call for Super (). Bug on API level > 11.}
I just do not make the call to . Super () and everything works great. I Hope This would save you some time.
EDIT: After some more on the known bug in the support package.If you need to save the instance, and add something to your outstate Bundle you can use the following:
@Overrideprotected void Onsaveinstancestate (Bundle outstate) { outstate.putstring ("workaround_for_bug_19917_ KEY "," Workaround_for_bug_19917_value "); Super.onsaveinstancestate (outstate);}
EDIT2: This could also occur if you were trying to perform a transaction after your Activity was gone in Backgrou nd. To avoid the should use Commitallowingstateloss ()
EDIT3: The above solutions were fixing issues in the early SUPPORT.V4 libraries from what I can remember. But if you still has issues with this must also read @AlexLockwood ' s blog:fragment transactions & Activity Sta Te LossSummary from the blog post (but I strongly recommend you to read it):
never commit () transactions after OnPause () in Pre-honeycomb, and OnStop () on Post-honeycombBe careful when committing transactions inside Activity lifecycle methods. Use OnCreate (), onresumefragments () and Onpostresume ()Avoid performing transactions inside asynchronous callback methodsuse commitallowingstateloss () only as a last resort.
Android-illegalstateexception:can not perform this action after onsaveinstancestate