简体   繁体   中英

savedInstanceState is always null after activity gets destroyed

I've got parent and child activities. Parent activity stores custom state in onSaveInstanceState (super.onSaveInstanceState is called after all needed items are packed into bundle) and then the state is read in onCreate however savedInstanceState is always null for some reason.

Here is sequence of logged events on parent activity: onPause->onSaveInstanceState->onStop. Then child activity gets shown and when I press Up, parent activity fires onDestroy, then onCreate with null savedInstanceState.

I'm kind of out of ideas on the matter - please advise what I might be missing.

Thanks.

I am facing the same issue. My solution is change ParentActivity launch mode in manifest from default to

android:launchMode="singleTop"

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