Activity前后台、旋转、跳转生命周期变化

时间:2022-09-04 14:43:46

Activity前后台

06-05 11:52:16.676 26146-26146/at.miao.miaoapplication E/miao_log: onCreate 启动
06-05 11:52:16.711 26146-26146/at.miao.miaoapplication E/miao_log: onStart
06-05 11:52:16.714 26146-26146/at.miao.miaoapplication E/miao_log: onResume
06-05 11:52:20.263 26146-26146/at.miao.miaoapplication E/miao_log: onPause 置后台
06-05 11:52:20.290 26146-26146/at.miao.miaoapplication E/miao_log: onSaveInstanceState:84598952
06-05 11:52:20.294 26146-26146/at.miao.miaoapplication E/miao_log: onStop
06-05 11:52:22.547 26146-26146/at.miao.miaoapplication E/miao_log: onRestart 置前台
06-05 11:52:22.550 26146-26146/at.miao.miaoapplication E/miao_log: onStart
06-05 11:52:22.552 26146-26146/at.miao.miaoapplication E/miao_log: onResume
06-05 11:52:23.837 26146-26146/at.miao.miaoapplication E/miao_log: onPause 置后台
06-05 11:52:23.856 26146-26146/at.miao.miaoapplication E/miao_log: onSaveInstanceState:329665
06-05 11:52:23.857 26146-26146/at.miao.miaoapplication E/miao_log: onStop
06-05 11:52:25.349 26146-26146/at.miao.miaoapplication E/miao_log: onRestart 置前台
06-05 11:52:25.351 26146-26146/at.miao.miaoapplication E/miao_log: onStart

06-05 11:52:25.351 26146-26146/at.miao.miaoapplication E/miao_log: onResume


Activity旋转时分两种情况

一、未配置android:configChanges

06-05 11:30:01.722 13831-13831/at.miao.miaoapplication E/miao_log: onCreate 启动
06-05 11:30:01.758 13831-13831/at.miao.miaoapplication E/miao_log: onStart
06-05 11:30:01.759 13831-13831/at.miao.miaoapplication E/miao_log: onResume
06-05 11:30:03.378 13831-13831/at.miao.miaoapplication E/miao_log: onPause 旋转
06-05 11:30:03.379 13831-13831/at.miao.miaoapplication E/miao_log: onSaveInstanceState:112746151
06-05 11:30:03.380 13831-13831/at.miao.miaoapplication E/miao_log: onStop
06-05 11:30:03.380 13831-13831/at.miao.miaoapplication E/miao_log: onDestroy
06-05 11:30:03.411 13831-13831/at.miao.miaoapplication E/miao_log: onCreate
06-05 11:30:03.416 13831-13831/at.miao.miaoapplication E/miao_log: onStart
06-05 11:30:03.416 13831-13831/at.miao.miaoapplication E/miao_log: onRestoreInstanceState:112746151
06-05 11:30:03.417 13831-13831/at.miao.miaoapplication E/miao_log: onResume
06-05 11:30:07.580 13831-13831/at.miao.miaoapplication E/miao_log: onPause 旋转
06-05 11:30:07.580 13831-13831/at.miao.miaoapplication E/miao_log: onSaveInstanceState:170875414
06-05 11:30:07.581 13831-13831/at.miao.miaoapplication E/miao_log: onStop
06-05 11:30:07.581 13831-13831/at.miao.miaoapplication E/miao_log: onDestroy
06-05 11:30:07.591 13831-13831/at.miao.miaoapplication E/miao_log: onCreate
06-05 11:30:07.602 13831-13831/at.miao.miaoapplication E/miao_log: onStart
06-05 11:30:07.602 13831-13831/at.miao.miaoapplication E/miao_log: onRestoreInstanceState:170875414

06-05 11:30:07.604 13831-13831/at.miao.miaoapplication E/miao_log: onResume

二、配置android:configChanges="orientation|screenSize"时

06-05 11:35:32.248 16692-16692/at.miao.miaoapplication E/miao_log: onCreate 启动
06-05 11:35:32.290 16692-16692/at.miao.miaoapplication E/miao_log: onStart
06-05 11:35:32.292 16692-16692/at.miao.miaoapplication E/miao_log: onResume
06-05 11:35:35.343 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:-1072973969 旋转
06-05 11:35:36.584 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:1157440192 旋转
06-05 11:35:38.306 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:-1072973969 旋转
06-05 11:35:39.803 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:1157440192 旋转
06-05 11:35:41.189 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:-1072973969 旋转

06-05 11:35:43.084 16692-16692/at.miao.miaoapplication E/miao_log: onConfigurationChanged:1157440192 旋转


Activity跳转

一、A与B启动模式均为:android:launchMode="standard"

06-05 12:40:02.545 16166-16166/at.miao.miaoapplication E/miao_log: A onCreate:16048185 启动A
06-05 12:40:02.588 16166-16166/at.miao.miaoapplication E/miao_log: A onStart
06-05 12:40:02.590 16166-16166/at.miao.miaoapplication E/miao_log: A onResume
06-05 12:40:03.467 16166-16166/at.miao.miaoapplication E/miao_log: A onPause 跳到B
06-05 12:40:03.513 16166-16166/at.miao.miaoapplication E/miao_log: B onCreate:205562
06-05 12:40:03.624 16166-16166/at.miao.miaoapplication E/miao_log: B onStart
06-05 12:40:03.626 16166-16166/at.miao.miaoapplication E/miao_log: B onResume
06-05 12:40:04.124 16166-16166/at.miao.miaoapplication E/miao_log: A onSaveInstanceState:195197950
06-05 12:40:04.127 16166-16166/at.miao.miaoapplication E/miao_log: A onStop
06-05 12:40:04.839 16166-16166/at.miao.miaoapplication E/miao_log: B onPause 跳到A
06-05 12:40:04.847 16166-16166/at.miao.miaoapplication E/miao_log: A onCreate:60098712
06-05 12:40:04.852 16166-16166/at.miao.miaoapplication E/miao_log: A onStart
06-05 12:40:04.853 16166-16166/at.miao.miaoapplication E/miao_log: A onResume
06-05 12:40:05.333 16166-16166/at.miao.miaoapplication E/miao_log: B onSaveInstanceState:25160283
06-05 12:40:05.336 16166-16166/at.miao.miaoapplication E/miao_log: B onStop
06-05 12:40:08.505 16166-16166/at.miao.miaoapplication E/miao_log: A onPause 跳到B
06-05 12:40:08.521 16166-16166/at.miao.miaoapplication E/miao_log: B onCreate:222875959
06-05 12:40:08.534 16166-16166/at.miao.miaoapplication E/miao_log: B onStart
06-05 12:40:08.537 16166-16166/at.miao.miaoapplication E/miao_log: B onResume
06-05 12:40:09.000 16166-16166/at.miao.miaoapplication E/miao_log: A onSaveInstanceState:182105664
06-05 12:40:09.001 16166-16166/at.miao.miaoapplication E/miao_log: A onStop
06-05 12:40:10.836 16166-16166/at.miao.miaoapplication E/miao_log: B onPause Back A
06-05 12:40:10.857 16166-16166/at.miao.miaoapplication E/miao_log: A onRestart:60098712
06-05 12:40:10.857 16166-16166/at.miao.miaoapplication E/miao_log: A onStart
06-05 12:40:10.858 16166-16166/at.miao.miaoapplication E/miao_log: A onResume
06-05 12:40:11.324 16166-16166/at.miao.miaoapplication E/miao_log: B onStop
06-05 12:40:11.325 16166-16166/at.miao.miaoapplication E/miao_log: B onDestroy
06-05 12:40:11.773 16166-16166/at.miao.miaoapplication E/miao_log: A onPause Back B
06-05 12:40:11.790 16166-16166/at.miao.miaoapplication E/miao_log: B onRestart:205562
06-05 12:40:11.791 16166-16166/at.miao.miaoapplication E/miao_log: B onStart
06-05 12:40:11.793 16166-16166/at.miao.miaoapplication E/miao_log: B onResume
06-05 12:40:12.283 16166-16166/at.miao.miaoapplication E/miao_log: A onStop
06-05 12:40:12.283 16166-16166/at.miao.miaoapplication E/miao_log: A onDestroy
06-05 12:40:12.615 16166-16166/at.miao.miaoapplication E/miao_log: B onPause Back A
06-05 12:40:12.629 16166-16166/at.miao.miaoapplication E/miao_log: A onRestart:16048185
06-05 12:40:12.630 16166-16166/at.miao.miaoapplication E/miao_log: A onStart
06-05 12:40:12.631 16166-16166/at.miao.miaoapplication E/miao_log: A onResume
06-05 12:40:13.131 16166-16166/at.miao.miaoapplication E/miao_log: B onStop

06-05 12:40:13.132 16166-16166/at.miao.miaoapplication E/miao_log: B onDestroy

一、A启动模式均为:android:launchMode="standard",B启动模式为android:launchMode="singleTop"