Fagment生命周期与Activity生命周期

来源:互联网 发布:linux vim 快捷键 编辑:程序博客网 时间:2024/05/18 03:15

Fagment生命周期:

http://blog.csdn.net/forever_crying/article/details/8238863

很详细,现在补充一下fragment通过intent跳转Activity过程中fragment与Activity的生命周期

场景演示 :

 FragmentManager切换到该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

Fragment跳转(INTENT)到Activity时:

fragment中打印出:onPauseActivity打印:onAttach   onCreate   onCreateView  onActivityCreated  onStart  onResume

Activity页面点击Back键返回Fragment时:

fragment中打印出:onResum后Activity打印onDestroy

Activity页面点击按钮(提交)即要走onDestroy:

Activity中打印出:onPause后 fragment中打印出:onResum后Activity打印onStop ---onDestroyView---onDestroy

Activity页面点击Home键时:

Activity中打印出:onPause  后 fragment中打印出:onStop    后 Activity中打印出: onStop

从桌面再次进入应用,显示的是Activity页面

fragment中打印出:onStart  后 Activity打印onResum


0 0
原创粉丝点击