Its possible to retain a Fragment
between Activities?
Lets say I have Activity A
with Fragment F_Left
placed at the left and Fragment F_Right
placed at the right. If I want to launch a new Activity and keep Fragment F_Left
... how can I do it?
Can I retain Fragment F_Left
state between activities?
Note that I want to launch a new Activity because Fragment F_Left
is my app menu and Fragment F_Right
changes completely the context of the user operations... and my app have many of operations, so it makes sense to have an Activity per operation.
I know its possible to retain Fragment
within an Activity
, but as Fragment
life cycle is closely tied to the container Activity
I don't know if this is possible keep Fragment
state between Activities.
If I want to launch a new Activity and keep Fragment F_Left... how can I do it?
Don't launch a new activity.
Can I retain Fragment F_Left state between activities?
Not automatically. It is not the same fragment. You would pass data between the activities for use by the fragment no differently than you would without any fragments at all.