1)第一次启动:onCreate->onAttach->onCreate->onCreateView->onActivityCreated->onStart->onResume->onResume
2)按下返回键:onPause->onPause->onStop->onStop->onDestroyView->onDestroy->onDetach->onDestroy
恢复时:因为按下返回键直接销毁了,所以恢复的时候会从新启动,重新执行onCreate->onAttach->……等方法
3)按下Home键:onPause->onPause->onStop->onStop
恢复时:onRestart->onStart->onStart->onResume->onResume
4)按下锁屏键:onPause->onPause->onStop->onStop
恢复时:onRestart->onStart->onStart->onResume->onResume
5)进入Back栈:onPause->onStop->onDestroyView
恢复时:onCreateView->onActivityCreated->onStart->onResume
通过以上分析,我们得出了这几个结论。
【1】onResume用来恢复保存的状态
【2】onPause用来保存当前的状态
【3】与Activity建立联系时会调用onAttach
【4】和activity分离的时调用onDetach
感谢:http://blog.csdn.net/forever_crying/article/details/8238863/