Most visited

Recently visited

Added in API level 1

DebugUtils

public class DebugUtils
extends Object

java.lang.Object
    android.util.DebugUtils


各种用于调试和记录的工具。

摘要(Summary)

公共方法(Public methods)

static boolean isObjectSelected(Object object)

根据 ANDROID_OBJECT_FILTER环境变量筛选对象。

继承方法(Inherited methods)

From class java.lang.Object

公共方法(Public methods)

isObjectSelected

Added in API level 1
boolean isObjectSelected (Object object)

根据ANDROID_OBJECT_FILTER环境变量筛选对象。 这个环境变量可以根据对象的类名和属性值来过滤对象。

以下是 ANDROID_OBJECT_FILTER的语法:

[email protected][email protected]=value2...

例子:

  • Select TextView instances: TextView
  • Select TextView instances of text "Loading" and bottom offset of 22: [email protected]=Loading.*@bottom=22

类名称和值是正则表达式。

这个类对调试和记录的目的很有用:

 if (DEBUG) {
   if (DebugUtils.isObjectSelected(childView) && LOGV_ENABLED) {
     Log.v(TAG, "Object " + childView + " logged!");
   }
 }
 

注意 :这种方法非常昂贵,因为它很大程度上依赖于正则表达式和反射。 调用此方法应始终从发行版二进制文件中删除,并在调试模式下尽可能避免。

参数(Parameters)
object Object: any object to match against the ANDROID_OBJECT_FILTER environement variable
返回(Returns)
boolean true if object is selected by the ANDROID_OBJECT_FILTER environment variable, false otherwise

Hooray!