Illegalstateexception: can not perform this action after onsaveinstancestate

Source: Internet
Author: User

 





















Today, I encountered a bug in the project navigation framework, as shown in:

This bug is very strange. It is the first time that it is running. No matter how you click OK! However, when you exit and come in again, the above error will be reported when you click it! I found this on the Internet. There will be a strange way to make a mistake like this! However,This operation cannot be executed in onsaveinstancestate ()After"Is the same. This type of error is not common. It is equivalent to a large set of errors. There are many error reporting methods in it!

The following describes my errors:

Click any item on the left side of this slide so that the corresponding content of the item is displayed on the right side. I use broadcast to achieve this effect. After some effort, I learned that there were no errors when I first entered the system, but why was there an error for the second time ?? Error can not perform this action after onsaveinstancestate is caused by the fact that every time I exit for the second time, all the activities have been killed and recycled. However, the broadcast still exists and is always ready to accept the broadcast sent from him. Therefore, the method is called immediately after the current activity is K:Onsaveinstancestate (), and then performs the fragment inbound stack operation through broadcast;

Therefore, the solution is to register the broadcast in the ondestory () method of the activity that receives the broadcast;


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.