今天的任务为日志跟踪理解activity生命周期
在QuizActivity.java文件中,
新增一个TAG常量
private static final String TAG="QuizActivity";
为onCreate方法添加日志输出代码
Log.d(TAG,"onCreate(Bundle) called");
覆盖更多生命周期方法:
@Override protected void onStart(){ super.onStart(); Log.d(TAG,"onStart() called"); } @Override protected void onResume(){ super.onResume(); Log.d(TAG,"onResume() called"); } @Override protected void onPause(){ super.onPause(); Log.d(TAG,"onPause() called"); } @Override protected void onStop(){ super.onStop(); Log.d(TAG,"onStop() called"); } @Override protected void onDestroy(){ super.onDestroy(); Log.d(TAG,"onDestroy() called"); }