Official website help documentation link:
http://developer.android.com/guide/components/fragments.html
Mainly look at two pictures, and run the code
1. Fragment's life cycle
Second, the comparison with the Activity life cycle
Scene demo: switch to this Fragment
11-29 14:26:35.095: D/AppListFragment(7649): onAttach
11-29 14:26:35.095: D/AppListFragment(7649): onCreate
11-29 14:26:35.095: D/AppListFragment(7649): onCreateView
11-29 14:26:35.100: D/AppListFragment(7649): onActivityCreated
11-29 14:26:35.120: D/AppListFragment(7649): onStart
11-29 14:26:35.120: D/AppListFragment(7649) : onResume
Screen goes off:
11-29 2:27:35.185: D/AppListFragment(7649): onPause
11-29 2:27:35.205: D/AppListFragment(7649): onSaveInstanceState
11-29 2:27:35.205: D/AppListFragment(7649): onStop
screen unlock
11-29 14:33:13.240: D/AppListFragment(7649): onStart
11-29 14:33:13.275: D/AppListFragment(7649): onResume
Switch to other Fragment:
11-29 14:33:33.655: D/AppListFragment(7649): onPause
11-29 14:33:33.655: D/AppListFragment(7649): onStop
11-29 14:33:33.660: D/ AppListFragment(7649): onDestroyView
Switch back to its own Fragment:
11-29 14:33:55.820: D/AppListFragment(7649): onCreateView
11-29 14:33:55.825: D/AppListFragment(7649): onActivityCreated
11-29 14:33:55.825: D/AppListFragment(7649): onStart
11-29 14:33:55.825: D/AppListFragment(7649): onResume
back to desktop
11-29 2:34:26.590: D/AppListFragment(7649): onPause
11-29 2:34:26.880: D/AppListFragment(7649): onSaveInstanceState
11-29 2:34:26.880: D/AppListFragment(7649): onStop
back to application
11-29 14:36:51.940: D/AppListFragment(7649): onStart
11-29 14:36:51.940: D/AppListFragment(7649): onResume
Exit the app
11-29 14:37:03.020: D/AppListFragment(7649): onPause
11-29 14:37:03.155: D/AppListFragment(7649): onStop
11-29 14:37:03.155: D/AppListFragment(7649): onDestroyView
11-29 14:37:03.165: D/AppListFragment(7649): onDestroy
11-29 14:37:03.165: D/AppListFragment(7649): onDetach
It has more life cycles than Activity, and it is completely connected to Activity, so everyone can make good use of it.
From: http://blog.csdn.net/forever_crying/article/details/8238863