i have a little app, that has a singe Activity and displays the content in fragments. So I navigate through my app by replacing the current fragment with the next one (and put them on the back stack).
The App is locked in Portrait, so the Activity gets never destroyed.
So my question is, how can I save the "instance state" of a fragment A before I navigate to fragment B, and restore the instance state when the back Button has been pressed and fragment A will be displayed on screen again.
As far as I know, onSaveInstanceState in a Fragment is bound to the activites lifecycle and get only called, when the activity gets destroyed. Since im using a single activity and use fragment transactions the activity get never destroyed and therefore onSaveInstanceState will never be called.
So the second way I have tried is to work with Fragment.getArguments() and Fragment.setArguments(). But once the Fragment has been instantiated, I can not change the arguments (IllegalStateException) .
So any other idea or hint how to deal with the fragments instance state in such a scenario (single activity, using fragment transactions) ?