开发学院手机开发Android 开发 Android SDK 在程序中输出日志及查看日志 阅读

Android SDK 在程序中输出日志及查看日志

 2010-05-26 22:17:00 来源:WEB开发网   
核心提示:Log.i(MyAndroid.ACTIVITY_TAG, "Haha , this is a INFO of MyAndroid. ");Log.w(MyAndroid.ACTIVITY_TAG, "Haha , this is a WARNING of MyAndroid. "

Log.i(MyAndroid.ACTIVITY_TAG, "Haha , this is a INFO of MyAndroid. ");

Log.w(MyAndroid.ACTIVITY_TAG, "Haha , this is a WARNING of MyAndroid. ");

return true;

}

}

}

package com.zijun;

import android.app.Activity;

import android.content.Context;

import android.graphics.Canvas;

import android.os.Bundle;

import android.util.Log;

import android.view.MotionEvent;

import android.view.View;

public class MyAndroid extends Activity {

protected static final String ACTIVITY_TAG="MyAndroid";

@Override

protected void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(new MyView(this));

}

public class MyView extends View {

public MyView(Context c) {

super(c);

}

@Override

protected void onDraw(Canvas canvas) {

}

@Override

public boolean onMotionEvent(MotionEvent event) {

Log.i(MyAndroid.ACTIVITY_TAG, "=============================");

Log.d(MyAndroid.ACTIVITY_TAG, "Haha , this is a DEBUG of MyAndroid. ");

Log.i(MyAndroid.ACTIVITY_TAG, "Haha , this is a INFO of MyAndroid. ");

Log.w(MyAndroid.ACTIVITY_TAG, "Haha , this is a WARNING of MyAndroid. ");

return true;

}

}

}

以上程序运行后, 在命令行执行 adb logcat -s MyAndroid:I

然后在手机模拟器的屏幕上 点击 拖动鼠标 就能看到相应的日志信息.

上一页  1 2 

Tags:Android SDK 程序

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接