FragmentManager manages all Fragments at the Activity level, and their life cycle will be tied to this parent Activity . The Fragment child manager manages all the Fragments at the Fragment level, and their life cycle will be tied to this parent Fragment .
So, for the architecture of your phone, add InnerFragment to your Activity using getFragmentManager() . When an Activity destroyed forever (via the return / finish() button), the FragmentManager destroy and release the InnerFragment for you.
For tablet architecture, add InnerFragments to Fragment using getChildFragmentManager() (in the latest support library). When a Fragment destroyed forever, the FragmentManager destroy and free InnerFragments for you.
You do not need to manage the release and destruction of your Fragments yourself. I would recommend recording the life cycle events of your Activities and Fragments so that you can watch how they go through their states and ensure proper behavior.
Steven byle
source share