android开发ui层都是建立在activity的基础上,也是整个android的四大组件之一。那么activity各阶段的生命方法的调用又是怎样的呢?让我们来一起探索-----------
一.activity被启动的阶段
1.protected void onApplyThemeResource(Theme theme, int resid, boolean first) {}
2.public View onCreateView(String name, Context context, AttributeSet attrs){}
3.public void onContentChanged(){}
4.protected void onCreate(Bundle savedInstanceState){}
5.protected void onStart(){}
6.protected void onResume(){}
7.public void onAttachedToWindow(){}
8.public View onCreatePanelView(int featureId){}
二.二个activity之间的跳转过程(A--->B)
1.A调用protected void onPause(){}
2.B走完一个完整的acitivy启动阶段的方法(activity被启动的阶段)
3.A调用protected void onSaveInstanceState(Bundle outState){}
4.A调用protected void onStop(){}
三.二个activity,当A启动B,在由B返回到A的过程
1.B调用protected void onPause(){}
2.A调用protected void onRestart(){}
3.A调用protected void onStart(){}
4.A调用protected void onResume(){}
5.B调用protected void onStop(){}
6.B调用protected void onDestroy()
7.B调用public void onDetachedFromWindow()
四.activity退出的过程
1.protected void onPause(){}
2.protected void onStop(){}
3.protected void onDestroy(){}
4.public void onDetachedFromWindow()
五.电源键被按时的过程
按电源键关闭屏幕
1.protected void onPause(){}
2.protected void onSaveInstanceState(Bundle outState){}
3.protected void onStop(){}
按电源键重新进入屏幕
1.protected void onRestart(){}
2.protected void onRestart(){}
3.protected void onResume()
六.home键的点击和重启启用的过程和电源键一致