I have an Activity that manages about four fragments. The activity decides when to add/replace/hide/show certain fragments. When my application is closed (due to low memory) and then reopened by the user, the fragments are not automatically readded to the fragment manager. How can I save the which fragments are added so that when the application is restarted the user will be brought to the same page they were on previously?
I assume use onSaveInstanceState() but I’m not sure exactly what to save…
Thanks
One thing I do is keeping track of the displayed screen as integer. Activity will hold a private int with current screen as its value.
This method won’t save everything on the screen as I only want to track the current page being displayed hence I only care about currentScreen. But you should get an idea anyway.
🙂