零基础Android学习笔记-02 安卓程序生命周期

一个安卓程序生命周期会经历7中状态,并不一定是每次都全部经历。Create,Start,ReStart,Pause,Resume,Stop,Destory.

重载方法,用helloWorld程序去体验下他们时候时候会执行。

 public class MainActivity extends Activity {
public final String TAG = "Main"; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "onCreate被执行了.");
} @Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Log.i(TAG, "onStart被执行了.");
} @Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
Log.i(TAG, "onRestart被执行了.");
} @Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.i(TAG, "onPause被执行了.");
} @Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.i(TAG, "onResume被执行了.");
} @Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Log.i(TAG, "onStop被执行了.");
} @Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.i(TAG, "onDestroy被执行了.");
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }

零基础Android学习笔记-02  安卓程序生命周期

上一篇:20145206邹京儒 web安全基础实践


下一篇:20145206邹京儒 Exp8 Web基础