[Android]當Activity啟動模式為singleTask時的生命週期
阿新 • • 發佈:2019-01-06
01-09 22:59:24.317 13063-13063/com.dongua.activitytest I/Activity1: onCreate:
01-09 22:59:24.319 13063-13063/com.dongua.activitytest I/Activity1: onStart:
01-09 22:59:24.321 13063-13063/com.dongua.activitytest I/Activity1: onResume:
01-09 22:59:29.501 13063-13063/com.dongua.activitytest I/Activity1: onStop:
01-09 22:59:37.846 13063-13063/com.dongua.activitytest I/Activity1: onRestart:
01-09 22:59:37.846 13063-13063/com.dongua.activitytest I/Activity1: onStart:
01-09 22:59:37.847 13063-13063/com.dongua.activitytest I/Activity1: onResume:
即再次啟動會呼叫onRestart-onStart-onResume
當2個都為singleTask的Activity互相跳轉時,則會出現如下情況
activity2 跳轉到 activity1 activity1再跳轉到activity2 後邊activity1執行了onDestroy方法被銷燬了
01-09 23:24:37.547 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onCreate:
01-09 23:24:37.548 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onStart:
01-09 23:24:37.550 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onResume:
01-09 23:24:40.636 7445-7445/com.dongua.activitytest I/Activity12: Activity1+onCreate:
01-09 23:24:40.638 7445-7445/com.dongua.activitytest I/Activity12: Activity1+onStart:
01-09 23:24:40.639 7445-7445/com.dongua.activitytest I/Activity12: Activity1+onResume:
01-09 23:24:40.971 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onStop:
01-09 23:24:52.602 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onRestart:
01-09 23:24:52.603 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onStart:
01-09 23:24:52.604 7445-7445/com.dongua.activitytest I/Activity12: Activity2+onResume:
01-09 23:24:52.960 7445-7445/com.dongua.activitytest I/Activity12: Activity1+onStop:
01-09 23:24:52.960 7445-7445/com.dongua.activitytest I/Activity12: Activity1+onDestroy: