Java.lang.IllegalStateException:Can not perform this action after onsaveinstancestate problem resolution

Source: Internet
Author: User

(1) I use fragment, OnStop but without OnDestroy switch (replace) fragment times Java.lang.IllegalStateException:Can not perform this Action after onsaveinstancestate error, the cause of the problem occurs, Is that I use Fragmenttransaction.commit, the solution: using Fragmenttransaction.commitallowingstateloss will not be an error

(2) This error occurred when using fragment today Illegalstateexception:can not perform this action after Onsaveinstancestate:

 This action after onsaveinstancestate at      Android.support.v4.app.FragmentManagerImpl.checkStateLoss ( Fragmentmanager.java:1314) at      android.support.v4.app.FragmentManagerImpl.enqueueAction ( Fragmentmanager.java:

is in the use of Fragmenttransition's Commit method to add a fragment, and later found on the official website of the relevant

Description: Http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss ()

public abstract int commitallowingstateloss () Added in API level 11

Like but allows, the commit to being executed after an activity's is commit() saved. This was dangerous because the commit can be lost if the activity needs to later being restored from it state, so this should Only being used for cases where it's okay for the UI state to change unexpectedly on the user.

Basically it means that the commit method I'm using is called after the activity's Onsaveinstancestate (), which makes an error, because

The Onsaveinstancestate method is called before the activity is about to be destroyed, to save the activity data, if you save the play state

Adding fragment to it will make a mistake. The solution is to replace the commit () method with Commitallowingstateloss ().

, the effect is the same.

Reference URL: http://blog.csdn.net/acetech_sean/article/details/9275485

Http://www.cnblogs.com/zgz345/archive/2013/03/04/2942553.html

Java.lang.IllegalStateException:Can not perform this action after onsaveinstancestate problem resolution

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.