This is something normal and expected in AOSP. Android kills the app process while saving all states and fragments in FragmentManager
, so you should retrieve back your fragment from the FragmentManager
you were commiting tour fragments to. See an example approach:
// Try to retrieve fragment from fragment manager
ExampleFragment exampleFragment = (ExampleFragment) getSupportFragmentManager().findFragmentByTag("ExampleFragment");
// Fragment was not saved in fragment manager, create a new instance
if (exampleFragment == null) exampleFragment = ExampleFragment.newInstance();
Note that I'm using getSupportFragmentManager()
as an example here (in the activity) but you have to use getChildFragmentManager()
within fragments.