Activity 跳转的生命周期变化

(1)Activity1跳转到Activity2的生命周期流程

 1.Activity1启动:
      Activity1: onCreate()
      Activity1: onStart()
      Activity1: onResume()

 2.点击按钮跳转到Activity2:
      Activity1: onPause()
      Activity2: onCreate()
      Activity2: onStart()
      Activity2: onResume()
      Activity1: onStop()

 3.从Activity2中返回:
      Activity2: onPause()
      Activity1: onRestart()
      Activity1: onStart()
      Activity1: onResume()
      Activity2: onStop()
      Activity2: onDestroy()

 4.Activity1退出
      Activity1: onPause()
      Activity1: onStop()
      Activity1: onDestroy()

(2) 假设Activity2为一个透明的activity

activity跳转的生命的周期如下

 1.Activity1启动:
      Activity1: onCreate()
      Activity1: onStart()
      Activity1: onResume()

 2.点击按钮跳转到Activity2:
      Activity1: onPause()
      Activity2: onCreate()
      Activity2: onStart()
      Activity2: onResume()

 3.从Activity2中返回:
      Activity2: onPause()
      Activity1: onResume()
      Activity2: onStop()
      Activity2: onDestroy()

 4.Activity1退出
      Activity1: onPause()
      Activity1: onStop()
      Activity1: onDestroy()

(3) 那在Activity之上弹出一个系统对话框,生命周期变化呢

 1.Activity启动:
      Activity1: onCreate()
      Activity1: onStart()
      Activity1: onResume()
 2.点击按钮弹出系统对话框
     这里发现并没有任何生命周期变化 ,原本还以为会走 
     onPause() 这个方法。

你可能感兴趣的:(Activity 跳转的生命周期变化)