Standard 标准模式启动
android:launchMode=“standard”
归纳:直接在栈顶新建一个Activity进行启动
生命周期:
===>开启一个Activity
I/LifecycleActivity_A: onCreate:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
===>退出
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_A: onStop:
I/LifecycleActivity_A: onDestroy:
SingleTop 栈顶启动
android:launchMode=“singleTop”
归纳:当栈顶TOP启动的Activity在栈内时,会轮询出栈,直到出栈到A然后进行复用
FLAG_ACTIVITY_CLEAR_TOP启动
栈顶复用不走newIntent(), 将栈内的需要启动的activity移到最顶处启动,并将上面的activity全部出栈销毁。
FLAG_ACTIVITY_SINGLE_TOP启动
走newInetent(), 如果在栈内则为Standard启动模式
生命周期:
FLAG_ACTIVITY_CLEAR_TOP启动
===> 启动A FLAG_ACTIVITY_NEW_TASK
I/LifecycleActivity_A: onCreate:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
I/LifecycleActivity_A: onPause:
===> 启动B FLAG_ACTIVITY_NEW_TASK
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_B: onCreate:
I/LifecycleActivity_B: onStart:
I/LifecycleActivity_B: onResume:
I/LifecycleActivity_A: onStop:
===> 启动A FLAG_ACTIVITY_CLEAR_TOP
I/LifecycleActivity_B: onPause:
I/LifecycleActivity_A: onDestroy:
I/LifecycleActivity_A: onCreate:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
I/LifecycleActivity_B: onStop:
I/LifecycleActivity_B: onDestroy:
===>A退出
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_A: onStop:
I/LifecycleActivity_A: onDestroy:
FLAG_ACTIVITY_SINGLE_TOP启动
===>启动A FLAG_ACTIVITY_NEW_TASK
I/LifecycleActivity_A: onCreate:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
===>启动A FLAG_ACTIVITY_CLEAR_TOP
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_A: onNewIntent:
I/LifecycleActivity_A: onResume:
===>A退出
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_A: onStop:
I/LifecycleActivity_A: onDestroy:
SingleTask 栈内复用模式
android:launchMode=“singleTask”
归纳:当栈内有需要启动的Activity时,则将该Activity移动到栈顶进行复用
FLAG_ACTIVITY_REORDER_TO_FRONT启动
===>启动A FLAG_ACTIVITY_NEW_TASK
I/LifecycleActivity_A: onCreate:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
===> 启动B FLAG_ACTIVITY_NEW_TASK
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_B: onCreate:
I/LifecycleActivity_B: onStart:
I/LifecycleActivity_B: onResume:
I/LifecycleActivity_A: onStop:
===> 启动A FLAG_ACTIVITY_REORDER_TO_FRONT
I/LifecycleActivity_B: onPause:
I/LifecycleActivity_A: onNewIntent:
I/LifecycleActivity_A: onRestart:
I/LifecycleActivity_A: onStart:
I/LifecycleActivity_A: onResume:
I/LifecycleActivity_B: onStop:
===>A退出
I/LifecycleActivity_A: onPause:
I/LifecycleActivity_B: onRestart:
I/LifecycleActivity_B: onStart:
I/LifecycleActivity_B: onResume:
I/LifecycleActivity_A: onStop:
I/LifecycleActivity_A: onDestroy:
===>B退出
I/LifecycleActivity_B: onPause:
I/LifecycleActivity_B: onStop:
I/LifecycleActivity_B: onDestroy:
SingleInstance 单例启动模式
android:launchMode=“singleinstance”
归纳:单独创建一个栈控件启动这个Activity,常用于启动壁纸,电话,闹钟等界面实现。