I have an Activity A which launches a fragment F, which then gets replaced with another fragment F2.
A -> F -> F2
If I'm at F2, press the recents button, and go back into the app, I expect it to still show F2, but it instead shows F.
I'm replacing fragments using this code:
FragmentManager fragmentManager = activity.getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(container.getId(), StoryFragment.newInstance(story)).addToBackStack(null).commit();
I've tested this with different fragments, and it turns out that the problem is going from fragment to fragment. It doesn't matter which fragments they are, if there's a fragment that replaces itself with another fragment, then I will have this problem. For example, A -> F2 -> F3 will show F2 when it should show F3.
I've tried adding things to onSaveInstance and onPause, but haven't been successful in doing so. Any help is appreciated.