1、
2、
3、
4、
5、
6、
二、实现
1、编写代码如下:
package com.example.androidlife;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
public final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG,"onCreate method is executed·········");
}
@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;
}
@Override
protected void onRestart() {
super.onRestart();
Log.i(TAG,"onRestart method is executed·········");
}
@Override
protected void onResume() {
super.onResume();
Log.i(TAG,"onResume method is executed·········");
}
@Override
protected void onStop() {
super.onStop();
Log.i(TAG,"onStop method is executed·········");
}
@Override
protected void onPause() {
super.onPause();
Log.i(TAG,"onPause method is executed·········");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i(TAG,"onDestroy method is executed·········");
}
@Override
protected void onStart() {
super.onStart();
Log.i(TAG,"onStart method is executed·········");
}
}
2、新建logcat
单击
,这时你会看到以下界面(对着下图进行配置):
3、部署并运行该程序,这时我们可以看到以下结果: