Android 中一个 Activity 的标准生命周期可以参考「应用程序基础」中的活动的生命周期一节。
而下面是一些特定情况下的生命周期:
— 从 Launcher 中启动 —
onApplyThemeResource(Resources.Theme theme, int resid, boolean first)
onCreate()
onWindowAttributesChanged (WindowManager.LayoutParams params)
onContentChanged()
onStart()
(*onRestoreInstanceState(Bundle))
onPostCreate(Bundle)
onResume()
onPostResume()
onAttachedToWindow()
onWindowFocusChanged (boolean hasFocus) : true
— 按下 home 键 —
onUserInteraction()
onUserLeaveHint()
onSaveInstanceState()
onResume()
onPostResume()
onWindowFocusChanged (boolean hasFocus) : false
onCreateDescription() : null
onStop()
— 通过长按 Home 键以启动 —
onRestart()
onStart()
onResume()
onWindowFocusChanged (boolean hasFocus) : true
— 通过 Back 键终止 —
onUserInteraction()
onResume()
onWindowFocusChanged (boolean hasFocus) : false
onStop()
onDestroy()
onDetachedFromWindow()