public class

AccessibilityNodeInfoCompat

extends Object
java.lang.Object
   ↳ android.support.v4.view.accessibility.AccessibilityNodeInfoCompat

Class Overview

Helper for accessing AccessibilityNodeInfo introduced after API level 4 in a backwards compatible fashion.

Summary

Constants
int ACTION_CLEAR_FOCUS Action that unfocuses the node.
int ACTION_CLEAR_SELECTION Action that unselects the node.
int ACTION_FOCUS Action that focuses the node.
int ACTION_SELECT Action that selects the node.
Public Constructors
AccessibilityNodeInfoCompat(Object info)
Public Methods
void addAction(int action)
Adds an action that can be performed on the node.
void addChild(View child)
Adds a child.
boolean equals(Object obj)
Compares this instance with the specified object and indicates if they are equal.
List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText(String text)
Finds AccessibilityNodeInfos by text.
int getActions()
Gets the actions that can be performed on the node.
void getBoundsInParent(Rect outBounds)
Gets the node bounds in parent coordinates.
void getBoundsInScreen(Rect outBounds)
Gets the node bounds in screen coordinates.
AccessibilityNodeInfoCompat getChild(int index)
Get the child at given index.
int getChildCount()
Gets the number of children.
CharSequence getClassName()
Gets the class this node comes from.
CharSequence getContentDescription()
Gets the content description of this node.
CharSequence getPackageName()
Gets the package this node comes from.
AccessibilityNodeInfoCompat getParent()
Gets the parent.
CharSequence getText()
Gets the text of this node.
int getWindowId()
Gets the id of the window from which the info comes from.
int hashCode()
Returns an integer hash code for this object.
boolean isCheckable()
Gets whether this node is checkable.
boolean isChecked()
Gets whether this node is checked.
boolean isClickable()
Gets whether this node is clickable.
boolean isEnabled()
Gets whether this node is enabled.
boolean isFocusable()
Gets whether this node is focusable.
boolean isFocused()
Gets whether this node is focused.
boolean isLongClickable()
Gets whether this node is long clickable.
boolean isPassword()
Gets whether this node is a password.
boolean isScrollable()
Gets if the node is scrollable.
boolean isSelected()
Gets whether this node is selected.
static AccessibilityNodeInfoCompat obtain(AccessibilityNodeInfoCompat info)
Returns a cached instance if such is available or a new one is create.
static AccessibilityNodeInfoCompat obtain()
Returns a cached instance if such is available otherwise a new one.
static AccessibilityNodeInfoCompat obtain(View source)
Returns a cached instance if such is available otherwise a new one and sets the source.
boolean performAction(int action)
Performs an action on the node.
void recycle()
Return an instance back to be reused.
void setBoundsInParent(Rect bounds)
Sets the node bounds in parent coordinates.
void setBoundsInScreen(Rect bounds)
Sets the node bounds in screen coordinates.
void setCheckable(boolean checkable)
Sets whether this node is checkable.
void setChecked(boolean checked)
Sets whether this node is checked.
void setClassName(CharSequence className)
Sets the class this node comes from.
void setClickable(boolean clickable)
Sets whether this node is clickable.
void setContentDescription(CharSequence contentDescription)
Sets the content description of this node.
void setEnabled(boolean enabled)
Sets whether this node is enabled.
void setFocusable(boolean focusable)
Sets whether this node is focusable.
void setFocused(boolean focused)
Sets whether this node is focused.
void setLongClickable(boolean longClickable)
Sets whether this node is long clickable.
void setPackageName(CharSequence packageName)
Sets the package this node comes from.
void setParent(View parent)
Sets the parent.
void setPassword(boolean password)
Sets whether this node is a password.
void setScrollable(boolean scrollable)
Sets if the node is scrollable.
void setSelected(boolean selected)
Sets whether this node is selected.
void setSource(View source)
Sets the source.
void setText(CharSequence text)
Sets the text of this node.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ACTION_CLEAR_FOCUS

Action that unfocuses the node.

Constant Value: 2 (0x00000002)

public static final int ACTION_CLEAR_SELECTION

Action that unselects the node.

Constant Value: 8 (0x00000008)

public static final int ACTION_FOCUS

Action that focuses the node.

Constant Value: 1 (0x00000001)

public static final int ACTION_SELECT

Action that selects the node.

Constant Value: 4 (0x00000004)

Public Constructors

public AccessibilityNodeInfoCompat (Object info)

Public Methods

public void addAction (int action)

Adds an action that can be performed on the node.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
action The action.
Throws
IllegalStateException If called from an AccessibilityService.

public void addChild (View child)

Adds a child.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
child The child.
Throws
IllegalStateException If called from an AccessibilityService.

public boolean equals (Object obj)

Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

The general contract for the equals and hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

Parameters
obj the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText (String text)

Finds AccessibilityNodeInfos by text. The match is case insensitive containment. The search is relative to this info i.e. this info is the root of the traversed tree.

Note: It is a client responsibility to recycle the received info by calling recycle() to avoid creating of multiple instances.

Parameters
text The searched text.
Returns
  • A list of node info.

public int getActions ()

Gets the actions that can be performed on the node.

Returns
  • The bit mask of with actions.

public void getBoundsInParent (Rect outBounds)

Gets the node bounds in parent coordinates.

Parameters
outBounds The output node bounds.

public void getBoundsInScreen (Rect outBounds)

Gets the node bounds in screen coordinates.

Parameters
outBounds The output node bounds.

public AccessibilityNodeInfoCompat getChild (int index)

Get the child at given index.

Note: It is a client responsibility to recycle the received info by calling recycle() to avoid creating of multiple instances.

Parameters
index The child index.
Returns
  • The child node.
Throws
IllegalStateException If called outside of an AccessibilityService.

public int getChildCount ()

Gets the number of children.

Returns
  • The child count.

public CharSequence getClassName ()

Gets the class this node comes from.

Returns
  • The class name.

public CharSequence getContentDescription ()

Gets the content description of this node.

Returns
  • The content description.

public CharSequence getPackageName ()

Gets the package this node comes from.

Returns
  • The package name.

public AccessibilityNodeInfoCompat getParent ()

Gets the parent.

Note: It is a client responsibility to recycle the received info by calling recycle() to avoid creating of multiple instances.

Returns
  • The parent.

public CharSequence getText ()

Gets the text of this node.

Returns
  • The text.

public int getWindowId ()

Gets the id of the window from which the info comes from.

Returns
  • The window id.

public int hashCode ()

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
  • this object's hash code.

public boolean isCheckable ()

Gets whether this node is checkable.

Returns
  • True if the node is checkable.

public boolean isChecked ()

Gets whether this node is checked.

Returns
  • True if the node is checked.

public boolean isClickable ()

Gets whether this node is clickable.

Returns
  • True if the node is clickable.

public boolean isEnabled ()

Gets whether this node is enabled.

Returns
  • True if the node is enabled.

public boolean isFocusable ()

Gets whether this node is focusable.

Returns
  • True if the node is focusable.

public boolean isFocused ()

Gets whether this node is focused.

Returns
  • True if the node is focused.

public boolean isLongClickable ()

Gets whether this node is long clickable.

Returns
  • True if the node is long clickable.

public boolean isPassword ()

Gets whether this node is a password.

Returns
  • True if the node is a password.

public boolean isScrollable ()

Gets if the node is scrollable.

Returns
  • True if the node is scrollable, false otherwise.

public boolean isSelected ()

Gets whether this node is selected.

Returns
  • True if the node is selected.

public static AccessibilityNodeInfoCompat obtain (AccessibilityNodeInfoCompat info)

Returns a cached instance if such is available or a new one is create. The returned instance is initialized from the given info.

Parameters
info The other info.
Returns
  • An instance.

public static AccessibilityNodeInfoCompat obtain ()

Returns a cached instance if such is available otherwise a new one.

Returns
  • An instance.

public static AccessibilityNodeInfoCompat obtain (View source)

Returns a cached instance if such is available otherwise a new one and sets the source.

Returns
  • An instance.
See Also

public boolean performAction (int action)

Performs an action on the node.

Note: An action can be performed only if the request is made from an AccessibilityService.

Parameters
action The action to perform.
Returns
  • True if the action was performed.
Throws
IllegalStateException If called outside of an AccessibilityService.

public void recycle ()

Return an instance back to be reused.

Note: You must not touch the object after calling this function.

Throws
IllegalStateException If the info is already recycled.

public void setBoundsInParent (Rect bounds)

Sets the node bounds in parent coordinates.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
bounds The node bounds.
Throws
IllegalStateException If called from an AccessibilityService.

public void setBoundsInScreen (Rect bounds)

Sets the node bounds in screen coordinates.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
bounds The node bounds.
Throws
IllegalStateException If called from an AccessibilityService.

public void setCheckable (boolean checkable)

Sets whether this node is checkable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
checkable True if the node is checkable.
Throws
IllegalStateException If called from an AccessibilityService.

public void setChecked (boolean checked)

Sets whether this node is checked.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
checked True if the node is checked.
Throws
IllegalStateException If called from an AccessibilityService.

public void setClassName (CharSequence className)

Sets the class this node comes from.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
className The class name.
Throws
IllegalStateException If called from an AccessibilityService.

public void setClickable (boolean clickable)

Sets whether this node is clickable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
clickable True if the node is clickable.
Throws
IllegalStateException If called from an AccessibilityService.

public void setContentDescription (CharSequence contentDescription)

Sets the content description of this node.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
contentDescription The content description.
Throws
IllegalStateException If called from an AccessibilityService.

public void setEnabled (boolean enabled)

Sets whether this node is enabled.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
enabled True if the node is enabled.
Throws
IllegalStateException If called from an AccessibilityService.

public void setFocusable (boolean focusable)

Sets whether this node is focusable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
focusable True if the node is focusable.
Throws
IllegalStateException If called from an AccessibilityService.

public void setFocused (boolean focused)

Sets whether this node is focused.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
focused True if the node is focused.
Throws
IllegalStateException If called from an AccessibilityService.

public void setLongClickable (boolean longClickable)

Sets whether this node is long clickable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
longClickable True if the node is long clickable.
Throws
IllegalStateException If called from an AccessibilityService.

public void setPackageName (CharSequence packageName)

Sets the package this node comes from.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
packageName The package name.
Throws
IllegalStateException If called from an AccessibilityService.

public void setParent (View parent)

Sets the parent.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
parent The parent.
Throws
IllegalStateException If called from an AccessibilityService.

public void setPassword (boolean password)

Sets whether this node is a password.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
password True if the node is a password.
Throws
IllegalStateException If called from an AccessibilityService.

public void setScrollable (boolean scrollable)

Sets if the node is scrollable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
scrollable True if the node is scrollable, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setSelected (boolean selected)

Sets whether this node is selected.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
selected True if the node is selected.
Throws
IllegalStateException If called from an AccessibilityService.

public void setSource (View source)

Sets the source.

Parameters
source The info source.

public void setText (CharSequence text)

Sets the text of this node.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
text The text.
Throws
IllegalStateException If called from an AccessibilityService.