简体   繁体   中英

In Which scanario's do onSaveInstanceState(Bundle) and onRestoreInstanceState(Bundle) get triggered?

the only place where I notice these methods getting a call is when we rotate the screen. so do guys know of any other scenario where these methods will be triggered?

onSaveInstanceState: onSaveInstanceState method gets called before or after onStop() is called. This varies from Android version to version. In the older versions, it used to get before onStop() onRestoreInstanceState: This method gets triggered only when something was saved in onSaveInstanceState method. It gets called after onStart() For more reference https://www.journaldev.com/22621/android-onsaveinstancestate-onrestoreinstancestate[1] and https://medium.com/@doyouseeitmyway/save-and-restore-instance-state-made-easy-cf6f175f54b0

Hope you have your answer:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM