OnPause who was first called, has not been found based.
In the article mentioned at the beginning of this article, the author's test showsOnsaveinstancestate Run first. In this paper, the test results showrun after onsaveinstancestate. Third, in the above test. Only The Onsaveinstancestate method is called, and onrestoreinstancestatemethod has not been called. Usein the book "Android Development Art exploration". The system will onlythe activity is about to be destroyed and the opportunity to show it again is to callOnrestoreinstancestate method. such as:D, when the screen switch:in the event of an abnormally terminated activity, the system invokes theOnsaveinstancestate method to save the currentActivitythe state, whenOnce the activity is created again, the system will callonrestoreinstancestate, and putwhen activity is destroyedthe bundle objects saved by the Onsaveinstancestate method are passed to the same time as the parametersOnrestoreinstancestate andOnCreate method,When recovering data, selectOnrestoreinstancestate andOnCreate methods are all capable, but BothThere is a difference:once the Onrestoreinstancestate method is called, its number of parameters(Bundle savedinstancestate) must have a value. However, in the case of normal startup,of the OnCreate method(Bundle savedinstancestate) The value is null, so assume that theOnCreate method for data recovery. Justit is necessary to infer first,Assumptionssavedinstancestate is not NULL, the descriptionActivitywas rebuilt. We will be able to retrieve the previously saved data for recovery.
in addition, in terms of time. the invocation of the Onrestoreinstancestate method is after OnStart. official documentation suggests using the onrestoreinstancestate method to recover data.
E. If you do not want activity to be created again when the screen is rotated, you can add orientation to the Configchanges property:screensize This option is more special, it is related to the compile option. This option does not cause activity to restart when both Minsdkversion and Targetsdkversion in the compilation options are below 13 o'clock. Doing so will cause the activity to restart. Additionally, the activity does not restart, despite the associated configuration. However, the system calls the Onconfigurationchanged method, which can be processed according to the requirements. F, specify the screen:The ability to set android:screenorientation= "Portrait" in the manifest file, or to use setrequestedorientation in a Java file (Activityinfo.screen_ orientation_portrait);specified as a vertical screen,set android:screenorientation= in the manifest file "Landscape". or use Setrequestedorientation (activityinfo.screen_orientation_landscape) in Java files;specifies a horizontal screen. in both cases, when the orientation of the screen changes, no matter what method is called.
G. Exit Activity:
Android-activity life cycle