简体   繁体   中英

Will onRestoreInstanceState() still be called when activity is recreated?

Quick question: In some cases, an activity will need to be destroyed to free up resources. In that scenario, when the user navigates back to said activity, onCreate() will first be called. I'm asking if onRestoreInstanceState() will still be called if ever that happens.

当从先前保存的状态重新初始化活动时,在onStart()之后onStart() onRestoreInstanceState()方法,在此处以savedInstanceState给出

Yes, it will.

First onCreate() is called with the saved instance state as a bundle. Then onStart() is called. Then onRestoreInstanceState() is called with the same bundle that was passed to onCreate() .

This gives you the option to restore the state either in onCreate() or in onRestoreInstanceState() .

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