I have two fragments, FragmentA
and FragmentB
, the user can go from FragmentA
to FragmentB
Let's say FragmentA
has a local variable varA
. When the user is on FragmentA
and changes orientation I can save that variable with onSaveInstanceState
and then restore it in onViewCreated
. No problem there.
However, when the user is on FragmentB
and the orientation changes, onSaveInstanceState
is called for FragmentA
, but onViewCreated
is never called and the variable is never restored.
How can I restore the variable properly?