Android-illegalstateexception:can not perform this action after onsaveinstancestate

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.