Stay organized with collections
Save and categorize content based on your preferences.
DebugUtils
open class DebugUtils
Various utilities for debugging and logging.
Summary
Public methods |
open static Boolean |
Filters objects against the ANDROID_OBJECT_FILTER environment variable.
|
Public methods
isObjectSelected
open static fun isObjectSelected(object: Any!): Boolean
Filters objects against the ANDROID_OBJECT_FILTER
environment variable. This environment variable can filter objects based on their class name and attribute values.
Here is the syntax for ANDROID_OBJECT_FILTER
:
ClassName@attribute1=value1@attribute2=value2...
Examples:
- Select TextView instances:
TextView
- Select TextView instances of text "Loading" and bottom offset of 22:
TextView@text=Loading.*@bottom=22
The class name and the values are regular expressions.
This class is useful for debugging and logging purpose:
if (DEBUG) {
if (DebugUtils.isObjectSelected(childView) && LOGV_ENABLED) {
Log.v(TAG, "Object " + childView + " logged!");
}
}
NOTE: This method is very expensive as it relies heavily on regular expressions and reflection. Calls to this method should always be stripped out of the release binaries and avoided as much as possible in debug mode.
Parameters |
object |
Any!: any object to match against the ANDROID_OBJECT_FILTER environement variable |
Return |
Boolean |
true if object is selected by the ANDROID_OBJECT_FILTER environment variable, false otherwise |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# DebugUtils\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nDebugUtils\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/util/DebugUtils \"View this page in Java\") \n\n```\nopen class DebugUtils\n```\n\n|---|------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.util.DebugUtils](#) |\n\nVarious utilities for debugging and logging.\n\nSummary\n-------\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isObjectSelected](#isObjectSelected(kotlin.Any))`(`object:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Filters objects against the `ANDROID_OBJECT_FILTER` environment variable. |\n\nPublic methods\n--------------\n\n### isObjectSelected\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun isObjectSelected(object: Any!): Boolean\n```\n\nFilters objects against the `ANDROID_OBJECT_FILTER` environment variable. This environment variable can filter objects based on their class name and attribute values.\n\nHere is the syntax for `ANDROID_OBJECT_FILTER`:\n\n`ClassName@attribute1=value1@attribute2=value2...`\n\nExamples:\n\n- Select TextView instances: `TextView`\n- Select TextView instances of text \"Loading\" and bottom offset of 22: `TextView@text=Loading.*@bottom=22`\n\nThe class name and the values are regular expressions.\n\nThis class is useful for debugging and logging purpose: \n\n```kotlin\nif (DEBUG) {\n if (DebugUtils.isObjectSelected(childView) && LOGV_ENABLED) {\n Log.v(TAG, \"Object \" + childView + \" logged!\");\n }\n }\n \n```\n\n**NOTE**: This method is very expensive as it relies heavily on regular expressions and reflection. Calls to this method should always be stripped out of the release binaries and avoided as much as possible in debug mode.\n\n| Parameters ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `object` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!: any object to match against the ANDROID_OBJECT_FILTER environement variable |\n\n| Return ||\n|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if object is selected by the ANDROID_OBJECT_FILTER environment variable, false otherwise |"]]