package com.AndroidLog;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class AndroidLog extends Activity {
private static final String TAG = "AndroidLog";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG, "onCreate");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.i(TAG, "onPause()");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.i(TAG, "onPause()");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
Log.i(TAG, "onRestart()");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.i(TAG, "onResume()");
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Log.i(TAG, "onStart()");
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Log.i(TAG, "onStop()");
}
}
- Eclipse切換到DDMS. (Window > Open Perspective -> DDMS)
- 啟用LogCat (Window -> Show View -> LogCat)
- 可自定義過濾器 (按LogCat窗格上的綠色十字圖標)
- 在對話框輸入Log Tag
- LogCat會顯示在底部窗格
相關文章: 日誌類(android.util.Log)
沒有留言:
發佈留言