男人应似海  

Android中横竖屏切换时Activity的生命周期执行情况

1.默认情况下生命周期

(1)第一次进入界面

11-17 13:55:18.452: E/ImageListActivity(10586): onCreate

11-17 13:55:18.462: E/ImageListActivity(10586): onContentChanged

11-17 13:55:18.472: E/ImageListActivity(10586): onStart

11-17 13:55:18.482: E/ImageListActivity(10586): onPostCreate

11-17 13:55:18.482: E/ImageListActivity(10586): onResume

11-17 13:55:18.492: E/ImageListActivity(10586): onPostResume

(2)切换成横平时

11-17 13:56:47.622: E/ImageListActivity(10586): onPause

11-17 13:56:47.622: E/ImageListActivity(10586): onStop

11-17 13:56:47.622: E/ImageListActivity(10586): onDestroy

11-17 13:56:47.632: E/ImageListActivity(10586): onCreate

11-17 13:56:47.642: E/ImageListActivity(10586): onContentChanged

11-17 13:56:47.702: E/ImageListActivity(10586): onStart

11-17 13:56:47.702: E/ImageListActivity(10586): onPostCreate

11-17 13:56:47.702: E/ImageListActivity(10586): onResume

11-17 13:56:47.702: E/ImageListActivity(10586): onPostResume

(3)切换回竖屏时

11-17 13:57:17.682: E/ImageListActivity(10586): onPause

11-17 13:57:17.682: E/ImageListActivity(10586): onStop

11-17 13:57:17.682: E/ImageListActivity(10586): onDestroy

11-17 13:57:17.682: E/ImageListActivity(10586): onCreate

11-17 13:57:17.692: E/ImageListActivity(10586): onContentChanged

11-17 13:57:17.732: E/ImageListActivity(10586): onStart

11-17 13:57:17.732: E/ImageListActivity(10586): onPostCreate

11-17 13:57:17.732: E/ImageListActivity(10586): onResume

11-17 13:57:17.732: E/ImageListActivity(10586): onPostResume

 

2.在配置文件中设置Activity标签属性android:configChanges=”orientation”(具体请查看文章“Android禁止横竖屏切换或禁止横竖屏切换时重启Activity“)后的生命周期

(1)第一次进入界面

11-17 14:01:20.912: E/ImageScanActivity(10586): onCreate

11-17 14:01:20.922: E/ImageScanActivity(10586): onContentChanged

11-17 14:01:20.922: E/ImageScanActivity(10586): onStart

11-17 14:01:20.922: E/ImageScanActivity(10586): onPostCreate

11-17 14:01:20.922: E/ImageScanActivity(10586): onResume

11-17 14:01:20.922: E/ImageScanActivity(10586): onPostResume

11-17 14:01:20.992: E/ImageListActivity(10586): onStop

(2)切换成横平时

11-17 14:02:01.932: E/ImageScanActivity(10586): onConfigurationChanged

(3)切换回竖屏时

11-17 14:03:06.292: E/ImageScanActivity(10586): onConfigurationChanged

posted on 2011-11-19 12:06  男人应似海  阅读(2258)  评论(0编辑  收藏  举报