android_guides
android_guides copied to clipboard
Slight modification needed in Creating and Using Fragments guide
The Creating and Using Fragments guide needs slight modification in this section. Fragment Hiding vs Replace section states that
we call transaction.replace(...) to load a dynamic fragment which first removes the existing fragment from the activity invoking onStop and onDestroy for that fragment before adding the new fragment to the container.
This official android guide clearly states that fragment is killed when the parent activity is itself killed.
Stopped The fragment is not visible. Either the host activity has been stopped or the fragment has been removed from the activity but added to the back stack. A stopped fragment is still alive (all state and member information is retained by the system). However, it is no longer visible to the user and will be killed if the activity is killed.
Actually onPause(), onStop() and onDestroyView() are called after a fragment has been removed/replaced in a fragment transaction. You can refer the onDestroyView() explanation and see the fragment life cycle diagram for confirming the above statement.