在Activity中重载下9种事件函数,在调用不同函数时使用LogCat在Eclipse的控制台中输出调用日志。掌握Activity在启动、停止和销毁等不同阶段,9种重载函数的调用顺序,并掌握Android调试工具LogCat的使用方法
package com.example.administrator.myapplication;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
private static String Tag = "LifeCycle";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(Tag,"onCreate()");
}
@Override
public void onStart(){
super.onStart();
Log.i(Tag,"onStart()");
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState){
super.onRestoreInstanceState(savedInstanceState);
Log.i(Tag,"onRestoreInstanceState()");
}
@Override
public void onResume() {
super.onResume();
Log.i(Tag,"onResume()");
}
@Override
public void onRestart(){
super.onRestart();
Log.i(Tag,"onRestart()");
}
@Override
public void onPause(){
super.onPause();
Log.i(Tag,"onPause()");
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
Log.i(Tag,"onSaveInstanceState()");
}
@Override
public void onStop(){
super.onStop();
Log.i(Tag,"onStop()");
}
@Override
public void onDestroy(){
super.onDestroy();
Log.i(Tag,"onDestroy()");
}
}