熟悉日志记录是调试和学习Android的重要资源。Android的日子记录特性用于android.util包的Log类中
方法有:
Log.e 记录错误
Log.w()记录警告
Log.i()记录信息类的消息
log.d()记录debug的信息
Log.v() 记录Verbose消息
要为MyFirstApp应用程序添加日志支持。可以编辑MyFirstApp.java文件。
需要为使用Log类添加适当的import表达式
import android.unil.Log
在MyFirstAndroidApp类中,声明一个字符串常量。它将用于表达这个类产生的所有日志小心。可以使用Eclipse特性来过滤出你的日志消息
private static final String DEBUG_TAG="MyFirstAppLogging";
在OnCreate()方法中可以记录下一些小心
Log.i(DEBUG_TAG,“INFO about MyFirstAndroidApp”);