说明:
打印各个状态信息
熟悉启动顺序
java:
public class MainActivity extends Activity {
private static final String TAG = "ActivityDemo";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e(TAG, "ActivityDemo-->start onCreate");
}
@Override
protected void onStart() {
super.onStart();
Log.e(TAG, "ActivityDemo-->start onStart");
}
@Override
protected void onRestart() {
super.onRestart();
Log.e(TAG, "ActivityDemo-->start onRestart");
}
@Override
protected void onResume() {
super.onResume();
Log.e(TAG, "ActivityDemo-->start onResume");
}
@Override
protected void onPause() {
super.onPause();
Log.e(TAG, "ActivityDemo-->start onPause");
}
@Override
protected void onStop() {
super.onStop();
Log.e(TAG, "ActivityDemo-->start onStop");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.e(TAG, "ActivityDemo-->start onDestroy");
}
}
LogCat:
运行时log信息:
返回结束时log信息:
按home键log信息:
重新进入程序log信息: