API 21 adds a new attribute to the activity, as long as it is set to persistacrossreboots,activity and has the ability to persist, in addition to a new bundle, which is persistablebundle.
OnCreate (Bundle savedinstancestate, Persistablebundle persistentstate)
Same asonCreate(android.os.Bundle)But called-those activities created with the attributepersistableModeSet topersistAcrossReboots.
The persistence here differs from the traditional meaning of the onsaveinstancestate, Onrestoreinstancestate, and OnCreate methods that are specifically implemented in the activity overload.
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState)
public void onRestoreInstanceState(Bundle savedInstanceState, PersistableBundle persistentState)
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)
The Onsaveinstancestate and Onrestoreinstancestate methods are a way to save the disaster, they are not in the "normal" activity life cycle, only some unexpected anomalies will trigger them, such as the screen to switch, press the home button. After API 21, the Persistablebundle parameter is added, so that these methods have the ability to recover data after the system shutdown restart.
Just set the properties in the activity in manifest:
android:persistableMode="persistAcrossReboots"
You can then use the above three methods directly in the activity.
Also note that the API version is 21 and above.
Reference: http://developer.android.com/reference/android/app/Activity.html
Android Combat 26: Persistablemode and activity persistence
About OnCreate (Bundle savedinstancestate, Persistablebundle persistentstate)
About OnCreate (Bundle savedinstancestate, Persistablebundle persistentstate)