I have a MainActivity (MA) and a DetailActivity (DA), where MA contains a CursorLoader
displayed in a grid (RecyclerView
). If the app goes to the background (and is possibly destroyed) and then restarted/restored, then MA is always re-initialized on restart (grid has all data).
DA, on the other hand, contains a FragmentStatePagerAdapter
, which gets the same cursor (from MA) and creates a number of "pages" (Fragments) in a ViewPager
. Each such PageFragment
gets one row of the cursor in a Bundle (arguments) for display.
If the app goes to the background (but not destroyed) while showing DA, then the PageFragment
is restored nicely (with data). But if the app ends up being destroyed after showing DA, then the app is restored with only a blank fragment (no data).
How can I fix this? What do I look for? Is it that my DA (or probably PageFragment
) is not saving the state on becoming inactive, or is it a matter of handling the restore more properly?
I'm assuming it's the PageFragment
, and presumably not the DetailActivity
, that has to save and/or restore state more properly. I'm asking because maybe there is a very obvious explanation for this type of scenario, or at least I might get some clues on what to check.