I'm new to android, I have a fragment and it goes through onPause, destroyView, destroy, but onSaveInstanceState is never called.
Is is this expected?
How can I save the state?
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable(KEY_CATEGORY, category);
super.onSaveInstanceState(outState);
}
The system calls onSaveInstanceState
when it is about to remove your fragment from the memory/recreate it for any reason. It won't be called otherwise.
If this is your case and onSaveInstanceState
is still not called, a code snippet of your fragment might help.
This happens many times due to omitting the line of calling this method of the superclass. Like here , for example. Make sure you call it.
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.