Android开发 - Fragment与Activity生命周期比较
1.Fragment的生命周期 见下图 2.与Activity生命周期的对比 见下图 3. 代码场景演示实例 切换到该Fragment: AppListFragment(7649): onAttachAppListFragment(7649): onCreateAppListFragment(7649): onCreateViewAppListFragment(7649): onActivityCreatedAppListFragment(7649): onStartAppListFragment(7649): onResume 屏幕灭掉: AppListFragment(7649): onPauseAppListFragment(7649): onSaveInstanceStateAppListFragment(7649): onStop 屏幕解锁 AppListFragment(7649): onStartAppListFragment(7649): onResume 切换到其他Fragment:AppListFragment(7649): onPauseAppListFragment(7649): onStopAppListFragment(7649): onDestroyView 切换回本身的Fragment: AppListFragment(7649): onCreateViewAppListFragment(7649): onActivityCreatedAppListFragment(7649): onStartAppListFragment(7649): onResume 回到桌面 AppListFragment(7649): onPauseAppListFragment(7649): onSaveInstanceStateAppListFragment(7649): onStop 回到应用 D/AppListFragment(7649): onStartAppListFragment(7649): onResume 退出应用 AppListFragment(7649): onPauseAppListFragment(7649): onStopAppListFragment(7649): onDestroyViewAppListFragment(7649): onDestroyAppListFragment(7649): onDetach