xxv / android-lifecycle

A diagram of the Android Activity / Fragment lifecycle
5.26k stars 681 forks source link

Documented the case where a Fragment may rerun onAttach() and onCreate() #31

Open yorickhenning opened 6 years ago

yorickhenning commented 6 years ago

Documented the case where a Fragment is popped from a FragmentManager's back stack and reused. This causes the Fragment to recreate its child FragmentManager, reattach, and run onCreate() again.

It is not obvious that this might happen, but it can.

FWIW, this reinitialization causes the FragmentManager returned by Fragment.getChildFragmentManager() to change, making it unsafe to store the FragmentManager reference across this change in the Fragment.