to top
Android APIs
public class

AccessibilityNodeInfo

extends Object
implements Parcelable
java.lang.Object
   ↳ android.view.accessibility.AccessibilityNodeInfo

Class Overview

This class represents a node of the window content as well as actions that can be requested from its source. From the point of view of an AccessibilityService a window content is presented as tree of accessibility node info which may or may not map one-to-one to the view hierarchy. In other words, a custom view is free to report itself as a tree of accessibility node info.

Once an accessibility node info is delivered to an accessibility service it is made immutable and calling a state mutation method generates an error.

Please refer to AccessibilityService for details about how to obtain a handle to window content as a tree of accessibility node info as well as familiarizing with the security model.

Developer Guides

For more information about making applications accessible, read the Accessibility developer guide.

Summary

Constants
int ACTION_ACCESSIBILITY_FOCUS Action that gives accessibility focus to the node.
String ACTION_ARGUMENT_HTML_ELEMENT_STRING Argument for which HTML element to get moving to the next/previous HTML element.
String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT Argument for which movement granularity to be used when traversing the node text.
int ACTION_CLEAR_ACCESSIBILITY_FOCUS Action that clears accessibility focus of the node.
int ACTION_CLEAR_FOCUS Action that clears input focus of the node.
int ACTION_CLEAR_SELECTION Action that unselects the node.
int ACTION_CLICK Action that clicks on the node info.
int ACTION_FOCUS Action that gives input focus to the node.
int ACTION_LONG_CLICK Action that long clicks on the node.
int ACTION_NEXT_AT_MOVEMENT_GRANULARITY Action that requests to go to the next entity in this node's text at a given movement granularity.
int ACTION_NEXT_HTML_ELEMENT Action to move to the next HTML element of a given type.
int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY Action that requests to go to the previous entity in this node's text at a given movement granularity.
int ACTION_PREVIOUS_HTML_ELEMENT Action to move to the previous HTML element of a given type.
int ACTION_SCROLL_BACKWARD Action to scroll the node content backward.
int ACTION_SCROLL_FORWARD Action to scroll the node content forward.
int ACTION_SELECT Action that selects the node.
int FOCUS_ACCESSIBILITY The accessibility focus.
int FOCUS_INPUT The input focus.
int MOVEMENT_GRANULARITY_CHARACTER Movement granularity bit for traversing the text of a node by character.
int MOVEMENT_GRANULARITY_LINE Movement granularity bit for traversing the text of a node by line.
int MOVEMENT_GRANULARITY_PAGE Movement granularity bit for traversing the text of a node by page.
int MOVEMENT_GRANULARITY_PARAGRAPH Movement granularity bit for traversing the text of a node by paragraph.
int MOVEMENT_GRANULARITY_WORD Movement granularity bit for traversing the text of a node by word.
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<AccessibilityNodeInfo> CREATOR
Public Methods
void addAction(int action)
Adds an action that can be performed on the node.
void addChild(View child)
Adds a child.
void addChild(View root, int virtualDescendantId)
Adds a virtual child which is a descendant of the given root.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
boolean equals(Object object)
Compares this instance with the specified object and indicates if they are equal.
List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text)
Finds AccessibilityNodeInfos by text.
AccessibilityNodeInfo findFocus(int focus)
Find the view that has the specified focus type.
AccessibilityNodeInfo focusSearch(int direction)
Searches for the nearest view in the specified direction that can take the input focus.
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.
AccessibilityNodeInfo 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.
int getMovementGranularities()
Gets the movement granularities for traversing the text of this node.
CharSequence getPackageName()
Gets the package this node comes from.
AccessibilityNodeInfo 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 isAccessibilityFocused()
Gets whether this node is accessibility focused.
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.
boolean isVisibleToUser()
Sets whether this node is visible to the user.
static AccessibilityNodeInfo obtain(View root, int virtualDescendantId)
Returns a cached instance if such is available otherwise a new one and sets the source.
static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info)
Returns a cached instance if such is available or a new one is create.
static AccessibilityNodeInfo obtain()
Returns a cached instance if such is available otherwise a new one.
static AccessibilityNodeInfo 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.
boolean performAction(int action, Bundle arguments)
Performs an action on the node.
void recycle()
Return an instance back to be reused.
void setAccessibilityFocused(boolean focused)
Sets whether this node is accessibility focused.
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 setMovementGranularities(int granularities)
Sets the movement granularities for traversing the text of this node.
void setPackageName(CharSequence packageName)
Sets the package this node comes from.
void setParent(View parent)
Sets the parent.
void setParent(View root, int virtualDescendantId)
Sets the parent to be a virtual descendant of the given root.
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 root, int virtualDescendantId)
Sets the source to be a virtual descendant of the given root.
void setSource(View source)
Sets the source.
void setText(CharSequence text)
Sets the text of this node.
void setVisibleToUser(boolean visibleToUser)
Sets whether this node is visible to the user.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel parcel, int flags)
Flatten this object in to a Parcel.

Note: After the instance is written to a parcel it is recycled.

[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int ACTION_ACCESSIBILITY_FOCUS

Since: API Level 16

Action that gives accessibility focus to the node.

Constant Value: 64 (0x00000040)

public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING

Since: API Level 16

Argument for which HTML element to get moving to the next/previous HTML element.

Type: String
Actions: ACTION_NEXT_HTML_ELEMENT, ACTION_PREVIOUS_HTML_ELEMENT

Constant Value: "ACTION_ARGUMENT_HTML_ELEMENT_STRING"

public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT

Since: API Level 16

Argument for which movement granularity to be used when traversing the node text.

Type: int
Actions: ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Constant Value: "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"

public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS

Since: API Level 16

Action that clears accessibility focus of the node.

Constant Value: 128 (0x00000080)

public static final int ACTION_CLEAR_FOCUS

Since: API Level 14

Action that clears input focus of the node.

Constant Value: 2 (0x00000002)

public static final int ACTION_CLEAR_SELECTION

Since: API Level 14

Action that unselects the node.

Constant Value: 8 (0x00000008)

public static final int ACTION_CLICK

Since: API Level 16

Action that clicks on the node info.

Constant Value: 16 (0x00000010)

public static final int ACTION_FOCUS

Since: API Level 14

Action that gives input focus to the node.

Constant Value: 1 (0x00000001)

public static final int ACTION_LONG_CLICK

Since: API Level 16

Action that long clicks on the node.

Constant Value: 32 (0x00000020)

public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY

Since: API Level 16

Action that requests to go to the next entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.

Arguments: ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Example:

Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);

Constant Value: 256 (0x00000100)

public static final int ACTION_NEXT_HTML_ELEMENT

Since: API Level 16

Action to move to the next HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.

Arguments: ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments);

Constant Value: 1024 (0x00000400)

public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Since: API Level 16

Action that requests to go to the previous entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.

Arguments: ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Example:

Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);

Constant Value: 512 (0x00000200)

public static final int ACTION_PREVIOUS_HTML_ELEMENT

Since: API Level 16

Action to move to the previous HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.

Arguments: ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments);

Constant Value: 2048 (0x00000800)

public static final int ACTION_SCROLL_BACKWARD

Since: API Level 16

Action to scroll the node content backward.

Constant Value: 8192 (0x00002000)

public static final int ACTION_SCROLL_FORWARD

Since: API Level 16

Action to scroll the node content forward.

Constant Value: 4096 (0x00001000)

public static final int ACTION_SELECT

Since: API Level 14

Action that selects the node.

Constant Value: 4 (0x00000004)

public static final int FOCUS_ACCESSIBILITY

Since: API Level 16

The accessibility focus.

Constant Value: 2 (0x00000002)

public static final int FOCUS_INPUT

Since: API Level 16

The input focus.

Constant Value: 1 (0x00000001)

public static final int MOVEMENT_GRANULARITY_CHARACTER

Since: API Level 16

Movement granularity bit for traversing the text of a node by character.

Constant Value: 1 (0x00000001)

public static final int MOVEMENT_GRANULARITY_LINE

Since: API Level 16

Movement granularity bit for traversing the text of a node by line.

Constant Value: 4 (0x00000004)

public static final int MOVEMENT_GRANULARITY_PAGE

Since: API Level 16

Movement granularity bit for traversing the text of a node by page.

Constant Value: 16 (0x00000010)

public static final int MOVEMENT_GRANULARITY_PARAGRAPH

Since: API Level 16

Movement granularity bit for traversing the text of a node by paragraph.

Constant Value: 8 (0x00000008)

public static final int MOVEMENT_GRANULARITY_WORD

Since: API Level 16

Movement granularity bit for traversing the text of a node by word.

Constant Value: 2 (0x00000002)

Fields

public static final Creator<AccessibilityNodeInfo> CREATOR

Since: API Level 14

Public Methods

public void addAction (int action)

Since: API Level 14

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)

Since: API Level 14

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 void addChild (View root, int virtualDescendantId)

Since: API Level 16

Adds a virtual child which is a descendant of the given root. If virtualDescendantId is NO_ID the root is added as a child.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

Parameters
root The root of the virtual subtree.
virtualDescendantId The id of the virtual child.

public int describeContents ()

Since: API Level 14

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public boolean equals (Object object)

Since: API Level 14

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
object the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText (String text)

Since: API Level 14

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 AccessibilityNodeInfo findFocus (int focus)

Since: API Level 16

Find the view that has the specified focus type. The search starts from the view represented by this node info.

Parameters
focus The focus to find. One of FOCUS_INPUT or FOCUS_ACCESSIBILITY.
Returns
  • The node info of the focused view or null.

public AccessibilityNodeInfo focusSearch (int direction)

Since: API Level 16

Searches for the nearest view in the specified direction that can take the input focus.

Parameters
direction The direction. Can be one of: FOCUS_DOWN, FOCUS_UP, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, FOCUS_BACKWARD.
Returns
  • The node info for the view that can take accessibility focus.

public void getBoundsInParent (Rect outBounds)

Since: API Level 14

Gets the node bounds in parent coordinates.

Parameters
outBounds The output node bounds.

public void getBoundsInScreen (Rect outBounds)

Since: API Level 14

Gets the node bounds in screen coordinates.

Parameters
outBounds The output node bounds.

public AccessibilityNodeInfo getChild (int index)

Since: API Level 14

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 ()

Since: API Level 14

Gets the number of children.

Returns
  • The child count.

public CharSequence getClassName ()

Since: API Level 14

Gets the class this node comes from.

Returns
  • The class name.

public CharSequence getContentDescription ()

Since: API Level 14

Gets the content description of this node.

Returns
  • The content description.

public int getMovementGranularities ()

Since: API Level 16

Gets the movement granularities for traversing the text of this node.

Returns
  • The bit mask with granularities.

public CharSequence getPackageName ()

Since: API Level 14

Gets the package this node comes from.

Returns
  • The package name.

public AccessibilityNodeInfo getParent ()

Since: API Level 14

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 ()

Since: API Level 14

Gets the text of this node.

Returns
  • The text.

public int getWindowId ()

Since: API Level 14

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

Returns
  • The window id.

public int hashCode ()

Since: API Level 14

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 isAccessibilityFocused ()

Since: API Level 16

Gets whether this node is accessibility focused.

Returns
  • True if the node is accessibility focused.

public boolean isCheckable ()

Since: API Level 14

Gets whether this node is checkable.

Returns
  • True if the node is checkable.

public boolean isChecked ()

Since: API Level 14

Gets whether this node is checked.

Returns
  • True if the node is checked.

public boolean isClickable ()

Since: API Level 14

Gets whether this node is clickable.

Returns
  • True if the node is clickable.

public boolean isEnabled ()

Since: API Level 14

Gets whether this node is enabled.

Returns
  • True if the node is enabled.

public boolean isFocusable ()

Since: API Level 14

Gets whether this node is focusable.

Returns
  • True if the node is focusable.

public boolean isFocused ()

Since: API Level 14

Gets whether this node is focused.

Returns
  • True if the node is focused.

public boolean isLongClickable ()

Since: API Level 14

Gets whether this node is long clickable.

Returns
  • True if the node is long clickable.

public boolean isPassword ()

Since: API Level 14

Gets whether this node is a password.

Returns
  • True if the node is a password.

public boolean isScrollable ()

Since: API Level 14

Gets if the node is scrollable.

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

public boolean isSelected ()

Since: API Level 14

Gets whether this node is selected.

Returns
  • True if the node is selected.

public boolean isVisibleToUser ()

Since: API Level 16

Sets whether this node is visible to the user.

Returns
  • Whether the node is visible to the user.

public static AccessibilityNodeInfo obtain (View root, int virtualDescendantId)

Since: API Level 16

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

Parameters
root The root of the virtual subtree.
virtualDescendantId The id of the virtual descendant.
Returns
  • An instance.

public static AccessibilityNodeInfo obtain (AccessibilityNodeInfo info)

Since: API Level 14

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 AccessibilityNodeInfo obtain ()

Since: API Level 14

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

Returns
  • An instance.

public static AccessibilityNodeInfo obtain (View source)

Since: API Level 14

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

Parameters
source The source view.
Returns
  • An instance.
See Also

public boolean performAction (int action)

Since: API Level 14

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 boolean performAction (int action, Bundle arguments)

Since: API Level 16

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.
arguments A bundle with additional arguments.
Returns
  • True if the action was performed.
Throws
IllegalStateException If called outside of an AccessibilityService.

public void recycle ()

Since: API Level 14

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 setAccessibilityFocused (boolean focused)

Since: API Level 16

Sets whether this node is accessibility 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 accessibility focused.
Throws
IllegalStateException If called from an AccessibilityService.

public void setBoundsInParent (Rect bounds)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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 setMovementGranularities (int granularities)

Since: API Level 16

Sets the movement granularities for traversing the text of this node.

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

Parameters
granularities The bit mask with granularities.
Throws
IllegalStateException If called from an AccessibilityService.

public void setPackageName (CharSequence packageName)

Since: API Level 14

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)

Since: API Level 14

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 setParent (View root, int virtualDescendantId)

Since: API Level 16

Sets the parent to be a virtual descendant of the given root. If virtualDescendantId equals to NO_ID the root is set as the parent.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

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

Parameters
root The root of the virtual subtree.
virtualDescendantId The id of the virtual descendant.

public void setPassword (boolean password)

Since: API Level 14

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)

Since: API Level 14

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)

Since: API Level 14

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 root, int virtualDescendantId)

Since: API Level 16

Sets the source to be a virtual descendant of the given root. If virtualDescendantId is NO_ID the root is set as the source.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report themselves as a tree of virtual views, thus conveying their logical structure.

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

Parameters
root The root of the virtual subtree.
virtualDescendantId The id of the virtual descendant.

public void setSource (View source)

Since: API Level 14

Sets the source.

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

Parameters
source The info source.

public void setText (CharSequence text)

Since: API Level 14

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.

public void setVisibleToUser (boolean visibleToUser)

Since: API Level 16

Sets whether this node is visible to the user.

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

Parameters
visibleToUser Whether the node is visible to the user.
Throws
IllegalStateException If called from an AccessibilityService.

public String toString ()

Since: API Level 14

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel parcel, int flags)

Since: API Level 14

Flatten this object in to a Parcel.

Note: After the instance is written to a parcel it is recycled. You must not touch the object after calling this function.

Parameters
parcel The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.