I have a android fragment hosted in an activity. The activity is not overriding any onsaveInstanceState or onRestoreInstanceState methods. in my fragment i put the following code:
@Override
public void onDestroy() {
super.onDestroy();
Bundle b = new Bundle();
b.putParcelable("mymodel", myModel);
onSaveInstanceState(b);
}
when user hits the back button i see this being called (i know its not guaranteed for ondestroy to be called, thats not my point). so i put a break point and indeed this code gets called. Then i return to the activity and it opens the fragment but the savedInstanceState is null in oncreate and in onViewCreated. What am i doing wrong ? i thought i could call this manually to save state ?