Fix onsaveinstancestate Bug
This address: Http://blog.csdn.net/caroline_wendy
Bug:
Java.lang.IllegalStateException:Can not perform this action after onsaveinstancestate at ANDROID.SUPPORT.V4.APP.FRAGM Entmanagerimpl.checkstateloss (Unknown Source) at Android.support.v4.app.FragmentManagerImpl.enqueueAction (Unknown SOURCE) at Android.support.v4.app.BackStackRecord.commitInternal (Unknown source) at Android.support.v4.app.BackSta Ckrecord.commit (Unknown source) at Android.support.v4.app.FragmentTabHost.onAttachedToWindow (Unknown source) at a Droid.view.View.dispatchAttachedToWindow (view.java:12618) at Android.view.ViewGroup.dispatchAttachedToWindow ( viewgroup.java:2460) at Android.view.ViewGroup.dispatchAttachedToWindow (viewgroup.java:2467) at Android.view.ViewG Roup.dispatchattachedtowindow (viewgroup.java:2467) at Android.view.ViewGroup.dispatchAttachedToWindow ( viewgroup.java:2467) at Android.view.ViewGroup.dispatchAttachedToWindow (viewgroup.java:2467) at Android.view.ViewG Roup.dispatchattachedtowindow (viewgroup.java:2467) At Android.view.ViewRootImpl.performTraversals (viewrootimpl.java:1262) at Android.view.ViewRootImpl.doTraversal ( viewrootimpl.java:1045) at Android.view.viewrootimpl$traversalrunnable.run (viewrootimpl.java:5908) at Android.view . Choreographer$callbackrecord.run (choreographer.java:780) at Android.view.Choreographer.doCallbacks ( choreographer.java:593) at Android.view.Choreographer.doFrame (choreographer.java:562) at Android.view.Choreographe R$framedisplayeventreceiver.run (choreographer.java:766) at Android.os.Handler.handleCallback (handler.java:733) at Android.os.Handler.dispatchMessage (handler.java:95) at Android.os.Looper.loop (looper.java:136) at ANDROID.APP.ACT Ivitythread.main (activitythread.java:5336) at java.lang.reflect.Method.invokeNative (Native Method) at Java.lang.re Flect. Method.invoke (method.java:515) at Com.android.internal.os.zygoteinit$methodandargscaller.run (ZygoteInit.java:865 ) at Com.android.internal.os.ZygoteInit.maiN (zygoteinit.java:681) at Dalvik.system.NativeStart.main (Native Method)
Reference:http://stackoverflow.com/questions/7575921/ Illegalstateexception-can-not-perform-this-action-after-onsaveinstancestate-hhttp://stackoverflow.com/questions/14278763/ Call-onsaveinstancestate-without-calling-super-onsaveinstancestateoutstate
Solution:in
overloaded onsaveinstancestate () ,
do not call the Super () method , because calling the Super method, at API level greater than 11 o'clock, can
cause a crash .
@Overrideprotected void Onsaveinstancestate (Bundle outstate) { //no call for Super (). Bug on API level > 11.// super.onsaveinstancestate (outstate);}
the role of the Onsaveinstancestate () method:Onsaveinstancestate's invocation follows the principle that onsaveinstancestate will be called by the system when the activity is destroyed when the system "does not have user permission". This is the responsibility of the system because it has to provide an opportunity for the user to save the data.
super.onsaveinstancestate (outstate):The activity itself stores some values in the bundle, such as the state of the fragments, and if the super method is not called, the values are not saved, but the program does not crash.
Android-Fix onsaveinstancestate Bug