Activity 生命周期
首先看一下Android api中所提供的Activity生命周期图(不明白的,可以看完整篇文章,在回头看一下这个图,你会明白的):
publicclass ActivityDemo extends Activity {
privatestatic final String TAG ="ActivityDemo";
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.e(TAG, "start onCreate~~~");
}
@Override
protectedvoid onStart() {
super.onStart();
Log.e(TAG, "start onStart~~~");
}
@Override
protectedvoid onRestart() {
super.onRestart();
Log.e(TAG, "start onRestart~~~");
}
@Override
protectedvoid onResume() {
super.onResume();
Log.e(TAG, "start onResume~~~");
}
@Override
protectedvoid onPause() {
super.onPause();
Log.e(TAG, "start onPause~~~");
}
@Override
protectedvoid onStop() {
super.onStop();
Log.e(TAG, "start onStop~~~");
}
@Override
protectedvoid onDestroy() {
super.onDestroy();
Log.e(TAG, "start onDestroy~~~");
}
}