AccessibilityNodeInfoCompat

Added in 1.1.0

public class AccessibilityNodeInfoCompat


Helper for accessing android.view.accessibility.AccessibilityNodeInfo in a backwards compatible fashion.

Summary

Nested types

A class defining an action that can be performed on an AccessibilityNodeInfo.

Class with information if a node is a collection.

Class with information if a node is a collection item.

Builder for creating CollectionItemInfoCompat objects.

Class with information if a node is a range.

Class with information of touch delegated views and regions.

Constants

static final int

Action that gives accessibility focus to the node.

static final String
ACTION_ARGUMENT_COLUMN_INT = "android.view.accessibility.action.ARGUMENT_COLUMN_INT"

Argument for specifying the collection column to make visible on screen.

static final String
ACTION_ARGUMENT_DIRECTION_INT = "androidx.core.view.accessibility.action.ARGUMENT_DIRECTION_INT"

Argument to represent the direction when using ACTION_SCROLL_IN_DIRECTION.

static final String
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN = "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"

Argument for whether when moving at granularity to extend the selection or to move it otherwise.

static final String
ACTION_ARGUMENT_HTML_ELEMENT_STRING = "ACTION_ARGUMENT_HTML_ELEMENT_STRING"

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

static final String
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"

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

static final String
ACTION_ARGUMENT_MOVE_WINDOW_X = "ACTION_ARGUMENT_MOVE_WINDOW_X"

Argument for specifying the x coordinate to which to move a window.

static final String
ACTION_ARGUMENT_MOVE_WINDOW_Y = "ACTION_ARGUMENT_MOVE_WINDOW_Y"

Argument for specifying the y coordinate to which to move a window.

static final String
ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT = "android.view.accessibility.action.ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT"

Argument to represent the duration in milliseconds to press and hold a node.

static final String
ACTION_ARGUMENT_PROGRESS_VALUE = "android.view.accessibility.action.ARGUMENT_PROGRESS_VALUE"

Argument for specifying the progress value to set.

static final String
ACTION_ARGUMENT_ROW_INT = "android.view.accessibility.action.ARGUMENT_ROW_INT"

Argument for specifying the collection row to make visible on screen.

static final String
ACTION_ARGUMENT_SCROLL_AMOUNT_FLOAT = "androidx.core.view.accessibility.action.ARGUMENT_SCROLL_AMOUNT_FLOAT"

Argument to represent the scroll amount as a percent of the visible area of a node, with 1.0F as the default.

static final String
ACTION_ARGUMENT_SELECTION_END_INT = "ACTION_ARGUMENT_SELECTION_END_INT"

Argument for specifying the selection end.

static final String
ACTION_ARGUMENT_SELECTION_START_INT = "ACTION_ARGUMENT_SELECTION_START_INT"

Argument for specifying the selection start.

static final String
ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE = "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"

Argument for specifying the text content to set

static final int

Action that clears accessibility focus of the node.

static final int

Action that unfocuses the node.

static final int

Action that unselects the node.

static final int

Action that clicks on the node info.

static final int

Action to collapse an expandable node.

static final int
ACTION_COPY = 16384

Action to copy the current selection to the clipboard.

static final int
ACTION_CUT = 65536

Action to cut the current selection and place it to the clipboard.

static final int
ACTION_DISMISS = 1048576

Action to dismiss a dismissible node.

static final int
ACTION_EXPAND = 262144

Action to expand an expandable node.

static final int

Action that focuses the node.

static final int

Action that long clicks on the node.

static final int

Action that requests to go to the next entity in this node's text at a given movement granularity.

static final int

Action to move to the next HTML element of a given type.

static final int
ACTION_PASTE = 32768

Action to paste the current clipboard content.

static final int

Action that requests to go to the previous entity in this node's text at a given movement granularity.

static final int

Action to move to the previous HTML element of a given type.

static final int

Action to scroll the node content backward.

static final int

Action to scroll the node content forward.

static final int

Action that selects the node.

static final int

Action to set the selection.

static final int
ACTION_SET_TEXT = 2097152

Action that sets the text of the node.

static final String
EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH"

Integer argument specifying the end index of the requested text location data.

static final int

The maximum allowed length of the requested text location data.

static final String
EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX"

Integer argument specifying the start index of the requested text location data.

static final String
EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_KEY"

Key used to request and locate extra data for text character location.

static final int

Prefetching strategy that prefetches the ancestors of the requested node.

static final int

Prefetching strategy that prefetches the descendants of the requested node breadth-first.

static final int

Prefetching strategy that prefetches the descendants of the requested node depth-first.

static final int

Prefetching strategy that prefetches the descendants in a hybrid depth first and breadth first approach.

static final int

Prefetching strategy that prefetches the siblings of the requested node.

static final int

Prefetching flag that specifies prefetching should not be interrupted by a request to retrieve a node or perform an action on a node.

static final int

The accessibility focus.

static final int

The input focus.

static final int

Maximum batch size of prefetched nodes for a request.

static final int

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

static final int

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

static final int

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

static final int

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

static final int

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

Public constructors

This method is deprecated.

Use wrap instead.

Public methods

void

Adds an action that can be performed on the node.

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.

boolean

Gets if this node opens a popup or a dialog.

boolean
List<AccessibilityNodeInfoCompat>

Finds android.view.accessibility.AccessibilityNodeInfos by text.

List<AccessibilityNodeInfoCompat>

Finds AccessibilityNodeInfoCompats by the fully qualified view id's resource name where a fully qualified id is of the from "package:id/id_resource_name".

AccessibilityNodeInfoCompat
findFocus(int focus)

Find the view that has the specified focus type.

AccessibilityNodeInfoCompat
focusSearch(int direction)

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

List<AccessibilityNodeInfoCompat.AccessibilityActionCompat>

Gets the actions that can be performed on the node.

int

This method is deprecated.

Use getActionList instead.

@NonNull List<String>

Get the extra data available for this node.

void

This method is deprecated.

Use getBoundsInScreen instead.

void

Gets the node bounds in screen coordinates.

void

Gets the node bounds in window coordinates.

AccessibilityNodeInfoCompat
getChild(int index)

Get the child at given index.

@Nullable AccessibilityNodeInfoCompat
getChild(int index, int prefetchingStrategy)

Get the child at given index.

int

Gets the number of children.

CharSequence

Gets the class this node comes from.

AccessibilityNodeInfoCompat.CollectionInfoCompat

Gets the collection info if the node is a collection.

AccessibilityNodeInfoCompat.CollectionItemInfoCompat

Gets the collection item info if the node is a collection item.

@Nullable CharSequence

Returns the container title.

CharSequence

Gets the content description of this node.

int

Get the drawing order of the view corresponding it this node.

CharSequence

Gets the error text of this node.

@Nullable AccessibilityNodeInfo.ExtraRenderingInfo

Gets the extra rendering info if the node is meant to be refreshed with extra data to examine rendering related accessibility issues.

Bundle

Gets an optional bundle with extra data.

@Nullable CharSequence

Gets the hint text of this node.

Object

This method is deprecated.

Use unwrap instead.

int

Gets the input type of the source as defined by InputType.

AccessibilityNodeInfoCompat

Gets the node info for which the view represented by this info serves as a label for accessibility purposes.

AccessibilityNodeInfoCompat

Gets the node info which serves as the label of the view represented by this info for accessibility purposes.

int

Gets the node's live region mode.

int

Returns the maximum text length for this node.

long

Gets the minimum time duration between two content change events.

int

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

CharSequence

Gets the package this node comes from.

@Nullable CharSequence

Get the title of the pane represented by this node.

AccessibilityNodeInfoCompat

Gets the parent.

@Nullable AccessibilityNodeInfoCompat
getParent(int prefetchingStrategy)

Gets the parent.

AccessibilityNodeInfoCompat.RangeInfoCompat

Gets the range info if this node is a range.

@Nullable CharSequence

Gets the custom role description.

@Nullable CharSequence

Gets the state description of this node.

CharSequence

Gets the text of this node.

int

Gets the text selection end.

int

Gets the text selection start.

@Nullable CharSequence

Gets the tooltip text of this node.

@Nullable AccessibilityNodeInfoCompat.TouchDelegateInfoCompat

Get the TouchDelegateInfoCompat for touch delegate behavior with the represented view.

AccessibilityNodeInfoCompat

Gets the node after which this one is visited in accessibility traversal.

AccessibilityNodeInfoCompat

Gets the node before which this one is visited during traversal.

@Nullable String

Gets the unique id of this node.

String

Gets the fully qualified resource name of the source view's id.

AccessibilityWindowInfoCompat

Gets the window to which this node belongs.

int

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

boolean

Gets whether the node has setRequestInitialAccessibilityFocus.

int
boolean

Gets if the node's accessibility data is considered sensitive.

boolean

Gets whether this node is accessibility focused.

boolean

Gets whether this node is checkable.

boolean

Gets whether this node is checked.

boolean

Gets whether this node is clickable.

boolean

Gets if the content of this node is invalid.

boolean

Gets whether this node is context clickable.

boolean

Gets if the node can be dismissed.

boolean

Gets if the node is editable.

boolean

Gets whether this node is enabled.

boolean

Gets whether this node is focusable.

boolean

Gets whether this node is focused.

boolean

Gets if the node supports granular scrolling.

boolean

Returns whether node represents a heading.

boolean

Returns whether the node originates from a view considered important for accessibility.

boolean

Gets whether this node is long clickable.

boolean

Gets if the node is a multi line editable text.

boolean

Gets whether this node is a password.

boolean

Returns whether the node is explicitly marked as a focusable unit by a screen reader.

boolean

Gets if the node is scrollable.

boolean

Gets whether this node is selected.

boolean

Returns whether the node's text represents a hint for the user to enter text.

boolean

Returns whether node represents a text entry key that is part of a keyboard or keypad.

boolean

Gets if the node has selectable text.

boolean

Gets whether this node is visible to the user.

static AccessibilityNodeInfoCompat

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

static AccessibilityNodeInfoCompat

Returns a cached instance if such is available or a new one is create.

static AccessibilityNodeInfoCompat
obtain(View source)

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

static AccessibilityNodeInfoCompat
obtain(View root, int virtualDescendantId)

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

This method is deprecated.

Accessibility Object recycling is no longer necessary or functional.

boolean

Refreshes this info with the latest state of the view it represents.

boolean

Removes an action that can be performed on the node.

boolean

Removes a child.

boolean
removeChild(View root, int virtualDescendantId)

Removes a virtual child which is a descendant of the given root.

void
setAccessibilityDataSensitive(boolean accessibilityDataSensitive)

Sets whether this node's accessibility data is considered sensitive.

void
setAccessibilityFocused(boolean focused)

Sets whether this node is accessibility focused.

void

Set the extra data available for this node.

void

This method is deprecated.

Accessibility services should not care about these bounds.

void

Sets the node bounds in screen coordinates.

void

Sets the node bounds in window coordinates.

void
setCanOpenPopup(boolean opensPopup)

Sets if this node opens a popup or a dialog.

void
setCheckable(boolean checkable)

Sets whether this node is checkable.

void
setChecked(boolean checked)

Sets whether this node is checked.

void

Sets the class this node comes from.

void
setClickable(boolean clickable)

Sets whether this node is clickable.

void
setCollectionInfo(Object collectionInfo)
void
setCollectionItemInfo(Object collectionItemInfo)
void

Sets the container title for app-developer-defined container which can be any type of ViewGroup or layout.

void
setContentDescription(CharSequence contentDescription)

Sets the content description of this node.

void
setContentInvalid(boolean contentInvalid)

Sets if the content of this node is invalid.

void
setContextClickable(boolean contextClickable)

Sets whether this node is context clickable.

void
setDismissable(boolean dismissable)

Sets if the node can be dismissed.

void
setDrawingOrder(int drawingOrderInParent)

Set the drawing order of the view corresponding it this node.

void
setEditable(boolean editable)

Sets whether this node is editable.

void
setEnabled(boolean enabled)

Sets whether this node is enabled.

void

Sets the error text of this node.

void
setFocusable(boolean focusable)

Sets whether this node is focusable.

void
setFocused(boolean focused)

Sets whether this node is focused.

void
setGranularScrollingSupported(boolean granularScrollingSupported)

Sets if the node supports granular scrolling.

void
setHeading(boolean isHeading)

Sets whether the node represents a heading.

void

Sets the hint text of this node.

void
setImportantForAccessibility(boolean important)

Sets whether the node is considered important for accessibility.

void
setInputType(int inputType)

Sets the input type of the source as defined by InputType.

void
setLabelFor(View labeled)

Sets the view for which the view represented by this info serves as a label for accessibility purposes.

void
setLabelFor(View root, int virtualDescendantId)

Sets the view for which the view represented by this info serves as a label for accessibility purposes.

void

Sets the view which serves as the label of the view represented by this info for accessibility purposes.

void
setLabeledBy(View root, int virtualDescendantId)

Sets the view which serves as the label of the view represented by this info for accessibility purposes.

void
setLiveRegion(int mode)

Sets the node's live region mode.

void
setLongClickable(boolean longClickable)

Sets whether this node is long clickable.

void

Sets the maximum text length, or -1 for no limit.

void

Sets the minimum time duration between two content change events, which is used in throttling content change events in accessibility services.

void
setMovementGranularities(int granularities)

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

void
setMultiLine(boolean multiLine)

Sets if the node is a multi line editable text.

void

Sets the package this node comes from.

void

If this node represents a visually distinct region of the screen that may update separately from the rest of the window, it is considered a pane.

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
setQueryFromAppProcessEnabled(@NonNull View view, boolean enabled)

Connects this node to the View's root so that operations on this node can query the entire AccessibilityNodeInfoCompat tree and perform accessibility actions on nodes.

void

Sets the range info if this node is a range.

void
setRequestInitialAccessibilityFocus(
    boolean requestInitialAccessibilityFocus
)

Sets whether the node has requested initial accessibility focus.

void

Sets the custom role description.

void
setScreenReaderFocusable(boolean screenReaderFocusable)

Sets whether the node should be considered a focusable unit by a screen reader.

void
setScrollable(boolean scrollable)

Sets if the node is scrollable.

void
setSelected(boolean selected)

Sets whether this node is selected.

void
setShowingHintText(boolean showingHintText)

Sets whether the node's text represents a hint for the user to enter text.

void
setSource(View source)

Sets the source.

void
setSource(View root, int virtualDescendantId)

Sets the source to be a virtual descendant of the given root.

void

Sets the state description of this node.

void

Sets the text of this node.

void
setTextEntryKey(boolean isTextEntryKey)

Sets whether the node represents a text entry key that is part of a keyboard or keypad.

void
setTextSelectable(boolean selectableText)

Sets if the node has selectable text.

void
setTextSelection(int start, int end)

Sets the text selection start and end.

void

Sets the tooltip text of this node.

void

Set touch delegate info if the represented view has a android.view.TouchDelegate.

void

Sets the view whose node is visited after this one in accessibility traversal.

void
setTraversalAfter(View root, int virtualDescendantId)

Sets the node after which this one is visited in accessibility traversal.

void

Sets the view before whose node this one should be visited during traversal.

void
setTraversalBefore(View root, int virtualDescendantId)

Sets the node before which this one is visited during traversal.

void

Sets the unique id of this node.

void

Sets the fully qualified resource name of the source view's id.

void
setVisibleToUser(boolean visibleToUser)

Sets whether this node is visible to the user.

@NonNull String
AccessibilityNodeInfo
static AccessibilityNodeInfoCompat

Creates a new instance wrapping an android.view.accessibility.AccessibilityNodeInfo.

Constants

ACTION_ACCESSIBILITY_FOCUS

Added in 1.1.0
public static final int ACTION_ACCESSIBILITY_FOCUS = 64

Action that gives accessibility focus to the node.

ACTION_ARGUMENT_COLUMN_INT

Added in 1.1.0
public static final String ACTION_ARGUMENT_COLUMN_INT = "android.view.accessibility.action.ARGUMENT_COLUMN_INT"

Argument for specifying the collection column to make visible on screen.

Type: intActions:

ACTION_ARGUMENT_DIRECTION_INT

Added in 1.12.0
public static final String ACTION_ARGUMENT_DIRECTION_INT = "androidx.core.view.accessibility.action.ARGUMENT_DIRECTION_INT"

Argument to represent the direction when using ACTION_SCROLL_IN_DIRECTION.

The value of this argument can be one of:

ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

Added in 1.1.0
public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN = "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"

Argument for whether when moving at granularity to extend the selection or to move it otherwise.

Type: booleanActions:ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

ACTION_ARGUMENT_HTML_ELEMENT_STRING

Added in 1.1.0
public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING = "ACTION_ARGUMENT_HTML_ELEMENT_STRING"

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

Type: StringActions:ACTION_NEXT_HTML_ELEMENT, ACTION_PREVIOUS_HTML_ELEMENT

ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT

Added in 1.1.0
public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"

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

Type: intActions:ACTION_NEXT_AT_MOVEMENT_GRANULARITY, ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

ACTION_ARGUMENT_MOVE_WINDOW_X

Added in 1.1.0
public static final String ACTION_ARGUMENT_MOVE_WINDOW_X = "ACTION_ARGUMENT_MOVE_WINDOW_X"

Argument for specifying the x coordinate to which to move a window.

Type: intActions:

ACTION_ARGUMENT_MOVE_WINDOW_Y

Added in 1.1.0
public static final String ACTION_ARGUMENT_MOVE_WINDOW_Y = "ACTION_ARGUMENT_MOVE_WINDOW_Y"

Argument for specifying the y coordinate to which to move a window.

Type: intActions:

ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT

Added in 1.5.0
public static final String ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT = "android.view.accessibility.action.ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT"

Argument to represent the duration in milliseconds to press and hold a node.

Type: intActions:

ACTION_ARGUMENT_PROGRESS_VALUE

Added in 1.1.0
public static final String ACTION_ARGUMENT_PROGRESS_VALUE = "android.view.accessibility.action.ARGUMENT_PROGRESS_VALUE"

Argument for specifying the progress value to set.

Type: floatActions:

ACTION_ARGUMENT_ROW_INT

Added in 1.1.0
public static final String ACTION_ARGUMENT_ROW_INT = "android.view.accessibility.action.ARGUMENT_ROW_INT"

Argument for specifying the collection row to make visible on screen.

Type: intActions:

ACTION_ARGUMENT_SCROLL_AMOUNT_FLOAT

Added in 1.12.0
public static final String ACTION_ARGUMENT_SCROLL_AMOUNT_FLOAT = "androidx.core.view.accessibility.action.ARGUMENT_SCROLL_AMOUNT_FLOAT"

Argument to represent the scroll amount as a percent of the visible area of a node, with 1.0F as the default. Values smaller than 1.0F represent a partial scroll of the node, and values larger than 1.0F represent a scroll that extends beyond the currently visible node Rect. Setting this to POSITIVE_INFINITY or to another "too large" value should scroll to the end of the node. Negative values should not be used with this argument.

This argument should be used with the following scroll actions:

Example: if a view representing a list of items implements ACTION_SCROLL_FORWARD to scroll forward by an entire screen (one "page"), then passing a value of .25F via this argument should scroll that view only by 1/4th of a screen. Passing a value of 1.50F via this argument should scroll the view by 1 1/2 screens or to end of the node if the node doesn't extend to 1 1/2 screens.

This argument should not be used with the following scroll actions, which don't cleanly conform to granular scroll semantics:

Views that support this argument should set setGranularScrollingSupported to true. Clients should use isGranularScrollingSupported to check if granular scrolling is supported.

ACTION_ARGUMENT_SELECTION_END_INT

Added in 1.1.0
public static final String ACTION_ARGUMENT_SELECTION_END_INT = "ACTION_ARGUMENT_SELECTION_END_INT"

Argument for specifying the selection end.

Type: intActions:ACTION_SET_SELECTION

ACTION_ARGUMENT_SELECTION_START_INT

Added in 1.1.0
public static final String ACTION_ARGUMENT_SELECTION_START_INT = "ACTION_ARGUMENT_SELECTION_START_INT"

Argument for specifying the selection start.

Type: intActions:ACTION_SET_SELECTION

ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

Added in 1.1.0
public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE = "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"

Argument for specifying the text content to set

Type: CharSequenceActions:ACTION_SET_TEXT

See also
ACTION_SET_TEXT

ACTION_CLEAR_ACCESSIBILITY_FOCUS

Added in 1.1.0
public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS = 128

Action that clears accessibility focus of the node.

ACTION_CLEAR_FOCUS

Added in 1.1.0
public static final int ACTION_CLEAR_FOCUS = 2

Action that unfocuses the node.

ACTION_CLEAR_SELECTION

Added in 1.1.0
public static final int ACTION_CLEAR_SELECTION = 8

Action that unselects the node.

ACTION_CLICK

Added in 1.1.0
public static final int ACTION_CLICK = 16

Action that clicks on the node info.

See also
ACTION_CLICK

ACTION_COLLAPSE

Added in 1.1.0
public static final int ACTION_COLLAPSE = 524288

Action to collapse an expandable node.

See also
ACTION_COLLAPSE

ACTION_COPY

Added in 1.1.0
public static final int ACTION_COPY = 16384

Action to copy the current selection to the clipboard.

See also
ACTION_COPY

ACTION_CUT

Added in 1.1.0
public static final int ACTION_CUT = 65536

Action to cut the current selection and place it to the clipboard.

See also
ACTION_CUT

ACTION_DISMISS

Added in 1.1.0
public static final int ACTION_DISMISS = 1048576

Action to dismiss a dismissible node.

See also
ACTION_DISMISS

ACTION_EXPAND

Added in 1.1.0
public static final int ACTION_EXPAND = 262144

Action to expand an expandable node.

See also
ACTION_EXPAND

ACTION_FOCUS

Added in 1.1.0
public static final int ACTION_FOCUS = 1

Action that focuses the node.

See also
ACTION_FOCUS

ACTION_LONG_CLICK

Added in 1.1.0
public static final int ACTION_LONG_CLICK = 32

Action that long clicks on the node.

ACTION_NEXT_AT_MOVEMENT_GRANULARITY

Added in 1.1.0
public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 256

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<, ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEANExample: Move to the previous character and do not extend selection.

          

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

ACTION_NEXT_HTML_ELEMENT

Added in 1.1.0
public static final int ACTION_NEXT_HTML_ELEMENT = 1024

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_STRINGExample:

          

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

ACTION_PASTE

Added in 1.1.0
public static final int ACTION_PASTE = 32768

Action to paste the current clipboard content.

See also
ACTION_PASTE

ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Added in 1.1.0
public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 512

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<, ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEANExample: Move to the next character and do not extend selection.

          

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

ACTION_PREVIOUS_HTML_ELEMENT

Added in 1.1.0
public static final int ACTION_PREVIOUS_HTML_ELEMENT = 2048

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_STRINGExample:

          

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

ACTION_SCROLL_BACKWARD

Added in 1.1.0
public static final int ACTION_SCROLL_BACKWARD = 8192

Action to scroll the node content backward.

ACTION_SCROLL_FORWARD

Added in 1.1.0
public static final int ACTION_SCROLL_FORWARD = 4096

Action to scroll the node content forward.

ACTION_SELECT

Added in 1.1.0
public static final int ACTION_SELECT = 4

Action that selects the node.

See also
ACTION_SELECT

ACTION_SET_SELECTION

Added in 1.1.0
public static final int ACTION_SET_SELECTION = 131072

Action to set the selection. Performing this action with no arguments clears the selection.

Arguments:ACTION_ARGUMENT_SELECTION_START_INT, ACTION_ARGUMENT_SELECTION_END_INTExample:

          

  Bundle arguments = new Bundle();
  arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
  arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
  info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments);

ACTION_SET_TEXT

Added in 1.1.0
public static final int ACTION_SET_TEXT = 2097152

Action that sets the text of the node. Performing the action without argument, using null or empty CharSequence will clear the text. This action will also put the cursor at the end of text.

Arguments:ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCEExample:

          

  Bundle arguments = new Bundle();
  arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
      "android");
  info.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);

See also
ACTION_SET_TEXT

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH

Added in 1.9.0
public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH"

Integer argument specifying the end index of the requested text location data. Must be positive and no larger than EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH.

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH

Added in 1.9.0
public static final int EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH = 20000

The maximum allowed length of the requested text location data.

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX

Added in 1.9.0
public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX"

Integer argument specifying the start index of the requested text location data. Must be valid inside the CharSequence returned by getText.

EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY

Added in 1.9.0
public static final String EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY = "android.core.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_KEY"

Key used to request and locate extra data for text character location. This key requests that an array of android.graphics.RectFs be added to the extras. This request is made with refreshWithExtraData. The arguments taken by this request are two integers: EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX and EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH. The starting index must be valid inside the CharSequence returned by getText, and the length must be positive.

The data can be retrieved from the Bundle returned by getExtras using this string as a key for getParcelableArray. The android.graphics.RectF will be null for characters that either do not exist or are off the screen. {@see #refreshWithExtraData(String, Bundle)}

FLAG_PREFETCH_ANCESTORS

Added in 1.12.0
public static final int FLAG_PREFETCH_ANCESTORS = 1

Prefetching strategy that prefetches the ancestors of the requested node.

Ancestors will be prefetched before siblings and descendants.

FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST

Added in 1.12.0
public static final int FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST = 16

Prefetching strategy that prefetches the descendants of the requested node breadth-first.

This must not be combined with FLAG_PREFETCH_DESCENDANTS_HYBRID or FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST or this will trigger an IllegalArgumentException.

See also
FLAG_PREFETCH_ANCESTORS

for where to use these flags.

FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST

Added in 1.12.0
public static final int FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST = 8

Prefetching strategy that prefetches the descendants of the requested node depth-first.

This must not be combined with FLAG_PREFETCH_DESCENDANTS_HYBRID or FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST or this will trigger an IllegalArgumentException.

See also
FLAG_PREFETCH_ANCESTORS

for where to use these flags.

FLAG_PREFETCH_DESCENDANTS_HYBRID

Added in 1.12.0
public static final int FLAG_PREFETCH_DESCENDANTS_HYBRID = 4

Prefetching strategy that prefetches the descendants in a hybrid depth first and breadth first approach.

The children of the root node is prefetched before recursing on the children. This must not be combined with FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST or FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST or this will trigger an IllegalArgumentException.

See also
FLAG_PREFETCH_ANCESTORS

for where to use these flags.

FLAG_PREFETCH_SIBLINGS

Added in 1.12.0
public static final int FLAG_PREFETCH_SIBLINGS = 2

Prefetching strategy that prefetches the siblings of the requested node.

To avoid disconnected trees, this flag will also prefetch the parent. Siblings will be prefetched before descendants.

See also
FLAG_PREFETCH_ANCESTORS

for where to use these flags.

FLAG_PREFETCH_UNINTERRUPTIBLE

Added in 1.12.0
public static final int FLAG_PREFETCH_UNINTERRUPTIBLE = 32

Prefetching flag that specifies prefetching should not be interrupted by a request to retrieve a node or perform an action on a node.

See also
FLAG_PREFETCH_ANCESTORS

for where to use these flags.

FOCUS_ACCESSIBILITY

Added in 1.1.0
public static final int FOCUS_ACCESSIBILITY = 2

The accessibility focus.

FOCUS_INPUT

Added in 1.1.0
public static final int FOCUS_INPUT = 1

The input focus.

MAX_NUMBER_OF_PREFETCHED_NODES

Added in 1.12.0
public static final int MAX_NUMBER_OF_PREFETCHED_NODES = 50

Maximum batch size of prefetched nodes for a request.

MOVEMENT_GRANULARITY_CHARACTER

Added in 1.1.0
public static final int MOVEMENT_GRANULARITY_CHARACTER = 1

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

MOVEMENT_GRANULARITY_LINE

Added in 1.1.0
public static final int MOVEMENT_GRANULARITY_LINE = 4

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

MOVEMENT_GRANULARITY_PAGE

Added in 1.1.0
public static final int MOVEMENT_GRANULARITY_PAGE = 16

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

MOVEMENT_GRANULARITY_PARAGRAPH

Added in 1.1.0
public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 8

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

MOVEMENT_GRANULARITY_WORD

Added in 1.1.0
public static final int MOVEMENT_GRANULARITY_WORD = 2

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

Public constructors

AccessibilityNodeInfoCompat

Added in 1.1.0
Deprecated in 1.1.0
public AccessibilityNodeInfoCompat(Object info)

Creates a new instance wrapping an android.view.accessibility.AccessibilityNodeInfo.

Parameters
Object info

The info.

Public methods

addAction

Added in 1.1.0
public void addAction(
    AccessibilityNodeInfoCompat.AccessibilityActionCompat action
)

Adds an action that can be performed on the node.

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

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

Compatibility:

  • API <21: No-op

addAction

Added in 1.1.0
public void addAction(int action)

Adds an action that can be performed on the node.

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

Parameters
int action

The action.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

addChild

Added in 1.1.0
public void addChild(View child)

Adds a child.

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

Parameters
View child

The child.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

addChild

Added in 1.1.0
public void addChild(View root, int virtualDescendantId)

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
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual child.

canOpenPopup

Added in 1.1.0
public boolean canOpenPopup()

Gets if this node opens a popup or a dialog.

Returns
boolean

If the the node opens a popup.

equals

public boolean equals(Object obj)

findAccessibilityNodeInfosByText

Added in 1.1.0
public List<AccessibilityNodeInfoCompatfindAccessibilityNodeInfosByText(String text)

Finds android.view.accessibility.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.

Parameters
String text

The searched text.

Returns
List<AccessibilityNodeInfoCompat>

A list of node info.

findAccessibilityNodeInfosByViewId

Added in 1.1.0
public List<AccessibilityNodeInfoCompatfindAccessibilityNodeInfosByViewId(String viewId)

Finds AccessibilityNodeInfoCompats by the fully qualified view id's resource name where a fully qualified id is of the from "package:id/id_resource_name". For example, if the target application's package is "foo.bar" and the id resource name is "baz", the fully qualified resource id is "foo.bar:id/baz".

Note: The primary usage of this API is for UI test automation and in order to report the fully qualified view id if an AccessibilityNodeInfoCompat the client has to set the FLAG_REPORT_VIEW_IDS flag when configuring their android.accessibilityservice.AccessibilityService.

Parameters
String viewId

The fully qualified resource name of the view id to find.

Returns
List<AccessibilityNodeInfoCompat>

A list of node info.

findFocus

Added in 1.1.0
public AccessibilityNodeInfoCompat findFocus(int focus)

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

Parameters
int focus

The focus to find. One of FOCUS_INPUT or FOCUS_ACCESSIBILITY.

Returns
AccessibilityNodeInfoCompat

The node info of the focused view or null.

focusSearch

Added in 1.1.0
public AccessibilityNodeInfoCompat focusSearch(int direction)

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

Parameters
int direction

The direction. Can be one of: FOCUS_DOWN, FOCUS_UP, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, FOCUS_BACKWARD.

Returns
AccessibilityNodeInfoCompat

The node info for the view that can take accessibility focus.

getActionList

Added in 1.1.0
public List<AccessibilityNodeInfoCompat.AccessibilityActionCompatgetActionList()

Gets the actions that can be performed on the node.

Returns
List<AccessibilityNodeInfoCompat.AccessibilityActionCompat>

A list of AccessibilityActions.

Compatibility:

  • API <21: Always returns null

getActions

Added in 1.1.0
Deprecated in 1.9.0
public int getActions()

Gets the actions that can be performed on the node.

Returns
int

The bit mask of with actions.

getAvailableExtraData

Added in 1.8.0
public @NonNull List<StringgetAvailableExtraData()

Get the extra data available for this node.

Some data that is useful for some accessibility services is expensive to compute, and would place undue overhead on apps to compute all the time. That data can be requested with refreshWithExtraData.

Returns
@NonNull List<String>

An unmodifiable list of keys corresponding to extra data that can be requested.

getBoundsInParent

Added in 1.1.0
Deprecated in 1.2.0
public void getBoundsInParent(Rect outBounds)

Gets the node bounds in the viewParent's coordinates. getParent does not represent the source's viewParent. Instead it represents the result of getParentForAccessibility, which returns the closest ancestor where isImportantForAccessibility is true. So this method is not reliable.

Parameters
Rect outBounds

The output node bounds.

getBoundsInScreen

Added in 1.1.0
public void getBoundsInScreen(Rect outBounds)

Gets the node bounds in screen coordinates.

Parameters
Rect outBounds

The output node bounds.

getBoundsInWindow

Added in 1.12.0
public void getBoundsInWindow(@NonNull Rect outBounds)

Gets the node bounds in window coordinates.

When magnification is enabled, the bounds in window are scaled up by magnification scale and the positions are also adjusted according to the offset of magnification viewport. For example, it returns Rect(-180, -180, 0, 0) for original bounds Rect(10, 10, 100, 100), when the magnification scale is 2 and offsets for X and Y are both 200.

Compatibility:

  • API <19: No-op
Parameters
@NonNull Rect outBounds

The output node bounds.

getChild

Added in 1.1.0
public AccessibilityNodeInfoCompat getChild(int index)

Get the child at given index.

Parameters
int index

The child index.

Returns
AccessibilityNodeInfoCompat

The child node.

Throws
java.lang.IllegalStateException

If called outside of an AccessibilityService.

getChild

Added in 1.12.0
public @Nullable AccessibilityNodeInfoCompat getChild(int index, int prefetchingStrategy)

Get the child at given index.

Parameters
int index

The child index.

int prefetchingStrategy

the prefetching strategy.

Returns
@Nullable AccessibilityNodeInfoCompat

The child node.

Throws
java.lang.IllegalStateException

If called outside of an AccessibilityService and before calling setQueryFromAppProcessEnabled.

See also
getParent

for a description of prefetching.

getChildCount

Added in 1.1.0
public int getChildCount()

Gets the number of children.

Returns
int

The child count.

getClassName

Added in 1.1.0
public CharSequence getClassName()

Gets the class this node comes from.

Returns
CharSequence

The class name.

getCollectionInfo

Added in 1.1.0
public AccessibilityNodeInfoCompat.CollectionInfoCompat getCollectionInfo()

Gets the collection info if the node is a collection. A collection child is always a collection item.

getCollectionItemInfo

Added in 1.1.0
public AccessibilityNodeInfoCompat.CollectionItemInfoCompat getCollectionItemInfo()

Gets the collection item info if the node is a collection item. A collection item is always a child of a collection.

Returns
AccessibilityNodeInfoCompat.CollectionItemInfoCompat

The collection item info.

getContainerTitle

Added in 1.12.0
public @Nullable CharSequence getContainerTitle()

Returns the container title.

Compatibility:

  • API <19: Returns null
See also
setContainerTitle

for details.

getContentDescription

Added in 1.1.0
public CharSequence getContentDescription()

Gets the content description of this node.

Returns
CharSequence

The content description.

getDrawingOrder

Added in 1.1.0
public int getDrawingOrder()

Get the drawing order of the view corresponding it this node.

Drawing order is determined only within the node's parent, so this index is only relative to its siblings.

In some cases, the drawing order is essentially simultaneous, so it is possible for two siblings to return the same value. It is also possible that values will be skipped.

Returns
int

The drawing position of the view corresponding to this node relative to its siblings.

getError

Added in 1.1.0
public CharSequence getError()

Gets the error text of this node.

Returns
CharSequence

The error text.

getExtraRenderingInfo

Added in 1.9.0
public @Nullable AccessibilityNodeInfo.ExtraRenderingInfo getExtraRenderingInfo()

Gets the extra rendering info if the node is meant to be refreshed with extra data to examine rendering related accessibility issues.

getExtras

Added in 1.1.0
public Bundle getExtras()

Gets an optional bundle with extra data. The bundle is lazily created and never null.

Note: It is recommended to use the package name of your application as a prefix for the keys to avoid collisions which may confuse an accessibility service if the same key has different meaning when emitted from different applications.

Returns
Bundle

The bundle.

getHintText

Added in 1.1.0
public @Nullable CharSequence getHintText()

Gets the hint text of this node. Only applies to nodes where text can be entered.

Returns
@Nullable CharSequence

The hint text.

getInfo

Added in 1.1.0
Deprecated in 1.1.0
public Object getInfo()

getInputType

Added in 1.1.0
public int getInputType()

Gets the input type of the source as defined by InputType.

Returns
int

The input type.

getLabelFor

Added in 1.1.0
public AccessibilityNodeInfoCompat getLabelFor()

Gets the node info for which the view represented by this info serves as a label for accessibility purposes.

Returns
AccessibilityNodeInfoCompat

The labeled info.

getLabeledBy

Added in 1.1.0
public AccessibilityNodeInfoCompat getLabeledBy()

Gets the node info which serves as the label of the view represented by this info for accessibility purposes.

Returns
AccessibilityNodeInfoCompat

The label.

getLiveRegion

Added in 1.1.0
public int getLiveRegion()

Gets the node's live region mode.

A live region is a node that contains information that is important for the user and when it changes the user should be notified. For example, in a login screen with a TextView that displays an "incorrect password" notification, that view should be marked as a live region with mode ACCESSIBILITY_LIVE_REGION_POLITE.

It is the responsibility of the accessibility service to monitor TYPE_WINDOW_CONTENT_CHANGED events indicating changes to live region nodes and their children.

Returns
int

The live region mode, or ACCESSIBILITY_LIVE_REGION_NONE if the view is not a live region.

getMaxTextLength

Added in 1.1.0
public int getMaxTextLength()

Returns the maximum text length for this node.

Returns
int

The maximum text length, or -1 for no limit.

See also
setMaxTextLength

getMinDurationBetweenContentChangesMillis

Added in 1.10.0
public long getMinDurationBetweenContentChangesMillis()

Gets the minimum time duration between two content change events.

getMovementGranularities

Added in 1.1.0
public int getMovementGranularities()

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

Returns
int

The bit mask with granularities.

getPackageName

Added in 1.1.0
public CharSequence getPackageName()

Gets the package this node comes from.

Returns
CharSequence

The package name.

getPaneTitle

Added in 1.1.0
public @Nullable CharSequence getPaneTitle()

Get the title of the pane represented by this node.

Returns
@Nullable CharSequence

The title of the pane represented by this node, or null if this node does not represent a pane.

getParent

Added in 1.1.0
public AccessibilityNodeInfoCompat getParent()

Gets the parent.

Returns
AccessibilityNodeInfoCompat

The parent.

getParent

Added in 1.12.0
public @Nullable AccessibilityNodeInfoCompat getParent(int prefetchingStrategy)

Gets the parent.

Use prefetchingStrategy to determine the types of nodes prefetched from the app if the requested node is not in the cache and must be retrieved by the app. The default strategy for getParent is a combination of ancestor and sibling strategies. The app will prefetch until all nodes fulfilling the strategies are fetched, another node request is sent, or the maximum prefetch batch size of MAX_NUMBER_OF_PREFETCHED_NODES nodes is reached. To prevent interruption by another request and to force prefetching of the max batch size, use FLAG_PREFETCH_UNINTERRUPTIBLE.

Parameters
int prefetchingStrategy

the prefetching strategy.

Returns
@Nullable AccessibilityNodeInfoCompat

The parent.

Throws
java.lang.IllegalStateException

If called outside of an AccessibilityService and before calling setQueryFromAppProcessEnabled.

getRangeInfo

Added in 1.1.0
public AccessibilityNodeInfoCompat.RangeInfoCompat getRangeInfo()

Gets the range info if this node is a range.

getRoleDescription

Added in 1.1.0
public @Nullable CharSequence getRoleDescription()

Gets the custom role description.

Returns
@Nullable CharSequence

The role description.

getStateDescription

Added in 1.5.0
public @Nullable CharSequence getStateDescription()

Gets the state description of this node.

Returns
@Nullable CharSequence

the state description or null if android version smaller than 19.

getText

Added in 1.1.0
public CharSequence getText()

Gets the text of this node.

Returns
CharSequence

The text.

getTextSelectionEnd

Added in 1.1.0
public int getTextSelectionEnd()

Gets the text selection end.

Returns
int

The text selection end if there is selection or -1.

getTextSelectionStart

Added in 1.1.0
public int getTextSelectionStart()

Gets the text selection start.

Returns
int

The text selection start if there is selection or -1.

getTooltipText

Added in 1.1.0
public @Nullable CharSequence getTooltipText()

Gets the tooltip text of this node.

Returns
@Nullable CharSequence

The tooltip text.

getTouchDelegateInfo

Added in 1.2.0
public @Nullable AccessibilityNodeInfoCompat.TouchDelegateInfoCompat getTouchDelegateInfo()

Get the TouchDelegateInfoCompat for touch delegate behavior with the represented view. It is possible for the same node to be pointed to by several regions. Use getRegionAt to get touch delegate target Region, and getTargetForRegion for AccessibilityNodeInfoCompat from the given region.

Compatibility:

  • API <29: Always returns null
Returns
@Nullable AccessibilityNodeInfoCompat.TouchDelegateInfoCompat

TouchDelegateInfoCompat or null if there are no touch delegates in this node.

getTraversalAfter

Added in 1.1.0
public AccessibilityNodeInfoCompat getTraversalAfter()

Gets the node after which this one is visited in accessibility traversal. A screen-reader must visit the content of the other node before the content of this one.

Returns
AccessibilityNodeInfoCompat

The succeeding node if such or null.

getTraversalBefore

Added in 1.1.0
public AccessibilityNodeInfoCompat getTraversalBefore()

Gets the node before which this one is visited during traversal. A screen-reader must visit the content of this node before the content of the one it precedes.

Returns
AccessibilityNodeInfoCompat

The succeeding node if such or null.

getUniqueId

Added in 1.9.0
public @Nullable String getUniqueId()

Gets the unique id of this node.

Returns
@Nullable String

the unique id or null if android version smaller than 19.

getViewIdResourceName

Added in 1.1.0
public String getViewIdResourceName()

Gets the fully qualified resource name of the source view's id.

Note: The primary usage of this API is for UI test automation and in order to report the source view id of an AccessibilityNodeInfoCompat the client has to set the FLAG_REPORT_VIEW_IDS flag when configuring their android.accessibilityservice.AccessibilityService.

Returns
String

The id resource name.

getWindow

Added in 1.1.0
public AccessibilityWindowInfoCompat getWindow()

Gets the window to which this node belongs.

Returns
AccessibilityWindowInfoCompat

The window.

See also
getWindows

getWindowId

Added in 1.1.0
public int getWindowId()

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

Returns
int

The window id.

hasRequestInitialAccessibilityFocus

Added in 1.10.0
public boolean hasRequestInitialAccessibilityFocus()

Gets whether the node has setRequestInitialAccessibilityFocus.

Returns
boolean

True if the node has requested initial accessibility focus.

hashCode

public int hashCode()

isAccessibilityDataSensitive

Added in 1.12.0
public boolean isAccessibilityDataSensitive()

Gets if the node's accessibility data is considered sensitive.

Returns
boolean

True if the node's data is considered sensitive, false otherwise.

isAccessibilityFocused

Added in 1.1.0
public boolean isAccessibilityFocused()

Gets whether this node is accessibility focused.

Returns
boolean

True if the node is accessibility focused.

isCheckable

Added in 1.1.0
public boolean isCheckable()

Gets whether this node is checkable.

Returns
boolean

True if the node is checkable.

isChecked

Added in 1.1.0
public boolean isChecked()

Gets whether this node is checked.

Returns
boolean

True if the node is checked.

isClickable

Added in 1.1.0
public boolean isClickable()

Gets whether this node is clickable.

Returns
boolean

True if the node is clickable.

isContentInvalid

Added in 1.1.0
public boolean isContentInvalid()

Gets if the content of this node is invalid. For example, a date is not well-formed.

Returns
boolean

If the node content is invalid.

isContextClickable

Added in 1.1.0
public boolean isContextClickable()

Gets whether this node is context clickable.

Returns
boolean

True if the node is context clickable.

isDismissable

Added in 1.1.0
public boolean isDismissable()

Gets if the node can be dismissed.

Returns
boolean

If the node can be dismissed.

isEditable

Added in 1.1.0
public boolean isEditable()

Gets if the node is editable.

Returns
boolean

True if the node is editable, false otherwise.

isEnabled

Added in 1.1.0
public boolean isEnabled()

Gets whether this node is enabled.

Returns
boolean

True if the node is enabled.

isFocusable

Added in 1.1.0
public boolean isFocusable()

Gets whether this node is focusable.

Returns
boolean

True if the node is focusable.

isFocused

Added in 1.1.0
public boolean isFocused()

Gets whether this node is focused.

Returns
boolean

True if the node is focused.

isGranularScrollingSupported

Added in 1.12.0
public boolean isGranularScrollingSupported()

Gets if the node supports granular scrolling.

Compatibility:

  • Api <19: Returns false.
Returns
boolean

True if all scroll actions that could support ACTION_ARGUMENT_SCROLL_AMOUNT_FLOAT have done so, false otherwise.

isHeading

Added in 1.1.0
public boolean isHeading()

Returns whether node represents a heading.

Note: Returns true if either setHeading marks this node as a heading or if the node has a CollectionItemInfoCompat that marks it as such, to accommodate apps that use the now-deprecated API.

Returns
boolean

true if the node is a heading, false otherwise.

isImportantForAccessibility

Added in 1.1.0
public boolean isImportantForAccessibility()

Returns whether the node originates from a view considered important for accessibility.

Returns
boolean

true if the node originates from a view considered important for accessibility, false otherwise

isLongClickable

Added in 1.1.0
public boolean isLongClickable()

Gets whether this node is long clickable.

Returns
boolean

True if the node is long clickable.

isMultiLine

Added in 1.1.0
public boolean isMultiLine()

Gets if the node is a multi line editable text.

Returns
boolean

True if the node is multi line.

isPassword

Added in 1.1.0
public boolean isPassword()

Gets whether this node is a password.

Returns
boolean

True if the node is a password.

isScreenReaderFocusable

Added in 1.1.0
public boolean isScreenReaderFocusable()

Returns whether the node is explicitly marked as a focusable unit by a screen reader. Note that false indicates that it is not explicitly marked, not that the node is not a focusable unit. Screen readers should generally use other signals, such as isFocusable, or the presence of text in a node, to determine what should receive focus.

Returns
boolean

true if the node is specifically marked as a focusable unit for screen readers, false otherwise.

isScrollable

Added in 1.1.0
public boolean isScrollable()

Gets if the node is scrollable.

Returns
boolean

True if the node is scrollable, false otherwise.

isSelected

Added in 1.1.0
public boolean isSelected()

Gets whether this node is selected.

Returns
boolean

True if the node is selected.

isShowingHintText

Added in 1.1.0
public boolean isShowingHintText()

Returns whether the node's text represents a hint for the user to enter text. It should only be true if the node has editable text.

Returns
boolean

true if the text in the node represents a hint to the user, false otherwise.

isTextEntryKey

Added in 1.1.0
public boolean isTextEntryKey()

Returns whether node represents a text entry key that is part of a keyboard or keypad.

Returns
boolean

true if the node is a text entry key, false otherwise.

isTextSelectable

Added in 1.9.0
public boolean isTextSelectable()

Gets if the node has selectable text.

Services should use ACTION_SET_SELECTION for selection. Editable text nodes must also be selectable. But not all UIs will populate this field, so services should consider 'isTextSelectable | isEditable' to ensure they don't miss nodes with selectable text.

Compatibility:

  • Api <19: Returns false.
Returns
boolean

True if the node has selectable text.

See also
isEditable

isVisibleToUser

Added in 1.1.0
public boolean isVisibleToUser()

Gets whether this node is visible to the user.

Returns
boolean

Whether the node is visible to the user.

obtain

Added in 1.1.0
public static AccessibilityNodeInfoCompat obtain()

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

Returns
AccessibilityNodeInfoCompat

An instance.

obtain

Added in 1.1.0
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
AccessibilityNodeInfoCompat info

The other info.

Returns
AccessibilityNodeInfoCompat

An instance.

obtain

Added in 1.1.0
public static AccessibilityNodeInfoCompat obtain(View source)

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

Returns
AccessibilityNodeInfoCompat

An instance.

See also
setSource

obtain

Added in 1.1.0
public static AccessibilityNodeInfoCompat obtain(View root, int virtualDescendantId)

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

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual descendant.

Returns
AccessibilityNodeInfoCompat

An instance.

See also
setSource

performAction

Added in 1.1.0
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 android.accessibilityservice.AccessibilityService.

Parameters
int action

The action to perform.

Returns
boolean

True if the action was performed.

Throws
java.lang.IllegalStateException

If called outside of an AccessibilityService.

performAction

Added in 1.1.0
public boolean performAction(int action, Bundle arguments)

Performs an action on the node.

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

Parameters
int action

The action to perform.

Bundle arguments

A bundle with additional arguments.

Returns
boolean

True if the action was performed.

Throws
java.lang.IllegalStateException

If called outside of an AccessibilityService.

recycle

Added in 1.1.0
Deprecated in 1.10.0
public void recycle()

Return an instance back to be reused.

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

Throws
java.lang.IllegalStateException

If the info is already recycled.

refresh

Added in 1.1.0
public boolean refresh()

Refreshes this info with the latest state of the view it represents.

Note: If this method returns false this info is obsolete since it represents a view that is no longer in the view tree.

Returns
boolean

Whether the refresh succeeded.

removeAction

Added in 1.1.0
public boolean removeAction(
    AccessibilityNodeInfoCompat.AccessibilityActionCompat action
)

Removes an action that can be performed on the node. If the action was not already added to the node, calling this method has no effect.

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

Parameters
AccessibilityNodeInfoCompat.AccessibilityActionCompat action

The action to be removed.

Returns
boolean

The action removed from the list of actions.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

Compatibility:

  • API <21: Always returns false

removeChild

Added in 1.1.0
public boolean removeChild(View child)

Removes a child. If the child was not previously added to the node, calling this method has no effect.

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

Parameters
View child

The child.

Returns
boolean

true if the child was present

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

removeChild

Added in 1.1.0
public boolean removeChild(View root, int virtualDescendantId)

Removes a virtual child which is a descendant of the given root. If the child was not previously added to the node, calling this method has no effect.

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual child.

Returns
boolean

true if the child was present

See also
addChild

setAccessibilityDataSensitive

Added in 1.12.0
public void setAccessibilityDataSensitive(boolean accessibilityDataSensitive)

Sets whether this node's accessibility data is considered sensitive.

For SDK 34 and higher: when set to true the framework will hide this node from accessibility services with the isAccessibilityTool property set to false.

Otherwise, for SDK 19 and higher: the framework cannot hide this node but this property may be read by accessibility services to provide modified behavior for sensitive nodes.

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

Parameters
boolean accessibilityDataSensitive

True if the node's accessibility data is considered sensitive.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setAccessibilityFocused

Added in 1.1.0
public void setAccessibilityFocused(boolean focused)

Sets whether this node is accessibility focused.

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

Parameters
boolean focused

True if the node is accessibility focused.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setAvailableExtraData

Added in 1.8.0
public void setAvailableExtraData(@NonNull List<String> extraDataKeys)

Set the extra data available for this node.

Note: When a View passes in a non-empty list, it promises that it will populate the node's extras with corresponding pieces of information in addExtraDataToAccessibilityNodeInfo.

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

Parameters
@NonNull List<String> extraDataKeys

A list of types of extra data that are available.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setBoundsInParent

Added in 1.1.0
Deprecated in 1.2.0
public void setBoundsInParent(Rect bounds)

Sets the node bounds in the viewParent's coordinates. getParent does not represent the source's viewParent. Instead it represents the result of getParentForAccessibility, which returns the closest ancestor where isImportantForAccessibility is true. So this method is not reliable.

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

Parameters
Rect bounds

The node bounds.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setBoundsInScreen

Added in 1.1.0
public void setBoundsInScreen(Rect bounds)

Sets the node bounds in screen coordinates.

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

Parameters
Rect bounds

The node bounds.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setBoundsInWindow

Added in 1.12.0
public void setBoundsInWindow(@NonNull Rect bounds)

Sets the node bounds in window coordinates.

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

Compatibility:

  • API <19: No-op
Parameters
@NonNull Rect bounds

The node bounds.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setCanOpenPopup

Added in 1.1.0
public void setCanOpenPopup(boolean opensPopup)

Sets if this node opens a popup or a dialog.

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

Parameters
boolean opensPopup

If the the node opens a popup.

setCheckable

Added in 1.1.0
public void setCheckable(boolean checkable)

Sets whether this node is checkable.

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

Parameters
boolean checkable

True if the node is checkable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setChecked

Added in 1.1.0
public void setChecked(boolean checked)

Sets whether this node is checked.

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

Parameters
boolean checked

True if the node is checked.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setClassName

Added in 1.1.0
public void setClassName(CharSequence className)

Sets the class this node comes from.

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

Parameters
CharSequence className

The class name.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setClickable

Added in 1.1.0
public void setClickable(boolean clickable)

Sets whether this node is clickable.

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

Parameters
boolean clickable

True if the node is clickable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setCollectionInfo

Added in 1.1.0
public void setCollectionInfo(Object collectionInfo)

setCollectionItemInfo

Added in 1.1.0
public void setCollectionItemInfo(Object collectionItemInfo)

setContainerTitle

Added in 1.12.0
public void setContainerTitle(@Nullable CharSequence containerTitle)

Sets the container title for app-developer-defined container which can be any type of ViewGroup or layout. Container title will be used to group together related controls, similar to HTML fieldset. Or container title may identify a large piece of the UI that is visibly grouped together, such as a toolbar or a card, etc.

Container title helps to assist in navigation across containers and other groups. For example, a screen reader may use this to determine where to put accessibility focus.

Container title is different from pane titlesetPaneTitle which indicates that the node represents a window or activity.

Example: An app can set container titles on several non-modal menus, containing TextViews or ImageButtons that have content descriptions, text, etc. Screen readers can quickly switch accessibility focus among menus instead of child views. Other accessibility-services can easily find the menu.

Compatibility:

  • API <19: No-op
Parameters
@Nullable CharSequence containerTitle

The container title that is associated with a ViewGroup/Layout on the screen.

setContentDescription

Added in 1.1.0
public void setContentDescription(CharSequence contentDescription)

Sets the content description of this node.

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

Parameters
CharSequence contentDescription

The content description.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setContentInvalid

Added in 1.1.0
public void setContentInvalid(boolean contentInvalid)

Sets if the content of this node is invalid. For example, a date is not well-formed.

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

Parameters
boolean contentInvalid

If the node content is invalid.

setContextClickable

Added in 1.1.0
public void setContextClickable(boolean contextClickable)

Sets whether this node is context clickable.

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

Parameters
boolean contextClickable

True if the node is context clickable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setDismissable

Added in 1.1.0
public void setDismissable(boolean dismissable)

Sets if the node can be dismissed.

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

Parameters
boolean dismissable

If the node can be dismissed.

setDrawingOrder

Added in 1.1.0
public void setDrawingOrder(int drawingOrderInParent)

Set the drawing order of the view corresponding it this node.

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

Parameters
int drawingOrderInParent
Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setEditable

Added in 1.1.0
public void setEditable(boolean editable)

Sets whether this node is editable.

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

Parameters
boolean editable

True if the node is editable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setEnabled

Added in 1.1.0
public void setEnabled(boolean enabled)

Sets whether this node is enabled.

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

Parameters
boolean enabled

True if the node is enabled.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setError

Added in 1.1.0
public void setError(CharSequence error)

Sets the error text of this node.

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

Parameters
CharSequence error

The error text.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setFocusable

Added in 1.1.0
public void setFocusable(boolean focusable)

Sets whether this node is focusable.

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

Parameters
boolean focusable

True if the node is focusable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setFocused

Added in 1.1.0
public void setFocused(boolean focused)

Sets whether this node is focused.

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

Parameters
boolean focused

True if the node is focused.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setGranularScrollingSupported

Added in 1.12.0
public void setGranularScrollingSupported(boolean granularScrollingSupported)

Sets if the node supports granular scrolling. This should be set to true if all scroll actions which could support ACTION_ARGUMENT_SCROLL_AMOUNT_FLOAT have done so.

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

Compatibility:

  • Api <19: No-op.
Parameters
boolean granularScrollingSupported

True if the node supports granular scrolling, false otherwise.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setHeading

Added in 1.1.0
public void setHeading(boolean isHeading)

Sets whether the node represents a heading.

This method has no effect below API 19

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

Parameters
boolean isHeading

true if the node is a heading, false otherwise.

setHintText

Added in 1.1.0
public void setHintText(@Nullable CharSequence hintText)

Sets the hint text of this node. Only applies to nodes where text can be entered.

This method has no effect below API 19

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

Parameters
@Nullable CharSequence hintText

The hint text for this mode.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setImportantForAccessibility

Added in 1.1.0
public void setImportantForAccessibility(boolean important)

Sets whether the node is considered important for accessibility.

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

Parameters
boolean important

true if the node is considered important for accessibility, false otherwise

setInputType

Added in 1.1.0
public void setInputType(int inputType)

Sets the input type of the source as defined by InputType.

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

Parameters
int inputType

The input type.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setLabelFor

Added in 1.1.0
public void setLabelFor(View labeled)

Sets the view for which the view represented by this info serves as a label for accessibility purposes.

Parameters
View labeled

The view for which this info serves as a label.

setLabelFor

Added in 1.1.0
public void setLabelFor(View root, int virtualDescendantId)

Sets the view for which the view represented by this info serves as a label for accessibility purposes. If virtualDescendantId is NO_ID the root is set as the labeled.

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.

Parameters
View root

The root whose virtual descendant serves as a label.

int virtualDescendantId

The id of the virtual descendant.

setLabeledBy

Added in 1.1.0
public void setLabeledBy(View label)

Sets the view which serves as the label of the view represented by this info for accessibility purposes.

Parameters
View label

The view that labels this node's source.

setLabeledBy

Added in 1.1.0
public void setLabeledBy(View root, int virtualDescendantId)

Sets the view which serves as the label of the view represented by this info for accessibility purposes. If virtualDescendantId is NO_ID the root is set as the label.

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 android.accessibilityservice.AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
View root

The root whose virtual descendant labels this node's source.

int virtualDescendantId

The id of the virtual descendant.

setLiveRegion

Added in 1.1.0
public void setLiveRegion(int mode)

Sets the node's live region mode.

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

Parameters
int mode

The live region mode, or ACCESSIBILITY_LIVE_REGION_NONE if the view is not a live region.

setLongClickable

Added in 1.1.0
public void setLongClickable(boolean longClickable)

Sets whether this node is long clickable.

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

Parameters
boolean longClickable

True if the node is long clickable.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setMaxTextLength

Added in 1.1.0
public void setMaxTextLength(int max)

Sets the maximum text length, or -1 for no limit.

Typically used to indicate that an editable text field has a limit on the number of characters entered.

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

Parameters
int max

The maximum text length.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

See also
getMaxTextLength

setMinDurationBetweenContentChangesMillis

Added in 1.10.0
public void setMinDurationBetweenContentChangesMillis(long duration)

Sets the minimum time duration between two content change events, which is used in throttling content change events in accessibility services.

Example: An app can set MinDurationBetweenContentChanges as 1 min for a view which sends content change events to accessibility services one event per second. Accessibility service will throttle those content change events and only handle one event per minute for that view.

Parameters
long duration

the minimum duration between content change events.

See also
getContentChangeTypes

for all content change types.

setMovementGranularities

Added in 1.1.0
public void setMovementGranularities(int granularities)

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

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

Parameters
int granularities

The bit mask with granularities.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setMultiLine

Added in 1.1.0
public void setMultiLine(boolean multiLine)

Sets if the node is a multi line editable text.

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

Parameters
boolean multiLine

True if the node is multi line.

setPackageName

Added in 1.1.0
public void setPackageName(CharSequence packageName)

Sets the package this node comes from.

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

Parameters
CharSequence packageName

The package name.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setPaneTitle

Added in 1.1.0
public void setPaneTitle(@Nullable CharSequence paneTitle)

If this node represents a visually distinct region of the screen that may update separately from the rest of the window, it is considered a pane. Set the pane title to indicate that the node is a pane, and to provide a title for it.

This method has no effect below API 19

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

Parameters
@Nullable CharSequence paneTitle

The title of the window represented by this node.

setParent

Added in 1.1.0
public void setParent(View parent)

Sets the parent.

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

Parameters
View parent

The parent.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setParent

Added in 1.1.0
public void setParent(View root, int virtualDescendantId)

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 android.accessibilityservice.AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

This method is not supported on devices running API level <16 since the platform did not support virtual descendants of real views.

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual descendant.

setPassword

Added in 1.1.0
public void setPassword(boolean password)

Sets whether this node is a password.

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

Parameters
boolean password

True if the node is a password.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setQueryFromAppProcessEnabled

Added in 1.12.0
public void setQueryFromAppProcessEnabled(@NonNull View view, boolean enabled)

Connects this node to the View's root so that operations on this node can query the entire AccessibilityNodeInfoCompat tree and perform accessibility actions on nodes.

Testing or debugging tools should create this AccessibilityNodeInfoCompat node using onInitializeAccessibilityNodeInfo or AccessibilityNodeProviderCompat and call this method, then navigate and interact with the node tree by calling methods on the node. Calling this method more than once on the same node is a no-op. After calling this method, all nodes linked to this node (children, ancestors, etc.) are also queryable.

Here "query" refers to the following node operations:

This is intended for short-lived inspections from testing or debugging tools in the app process, as operations on this node tree will only succeed as long as the associated view hierarchy remains attached to a window. AccessibilityNodeInfoCompat objects can quickly become out of sync with their corresponding View objects; if you wish to inspect a changed or different view hierarchy then create a new node from any view in that hierarchy and call this method on that new node, instead of disabling &re-enabling the connection on the previous node.

Compatibility:

  • API <34: No-op
Parameters
@NonNull View view

The view that generated this node, or any view in the same view-root hierarchy.

boolean enabled

Whether to enable (true) or disable (false) querying from the app process.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService, or if provided a View that is not attached to a window.

setRangeInfo

Added in 1.1.0
public void setRangeInfo(AccessibilityNodeInfoCompat.RangeInfoCompat rangeInfo)

Sets the range info if this node is a range.

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

Parameters
AccessibilityNodeInfoCompat.RangeInfoCompat rangeInfo

The range info.

setRequestInitialAccessibilityFocus

Added in 1.10.0
public void setRequestInitialAccessibilityFocus(
    boolean requestInitialAccessibilityFocus
)

Sets whether the node has requested initial accessibility focus.

If the node hasRequestInitialAccessibilityFocus, this node would be one of candidates to be accessibility focused when the window appears.

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

Parameters
boolean requestInitialAccessibilityFocus

True if the node requests to receive initial accessibility focus.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setRoleDescription

Added in 1.1.0
public void setRoleDescription(@Nullable CharSequence roleDescription)

Sets the custom role description.

The role description allows you to customize the name for the view's semantic role. For example, if you create a custom subclass of android.view.View to display a menu bar, you could assign it the role description of "menu bar".

Warning: For consistency with other applications, you should not use the role description to force accessibility services to describe standard views (such as buttons or checkboxes) using specific wording. For example, you should not set a role description of "check box" or "tick box" for a standard android.widget.CheckBox. Instead let accessibility services decide what feedback to provide.

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

Parameters
@Nullable CharSequence roleDescription

The role description.

setScreenReaderFocusable

Added in 1.1.0
public void setScreenReaderFocusable(boolean screenReaderFocusable)

Sets whether the node should be considered a focusable unit by a screen reader.

This method has no effect below API 19

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

Parameters
boolean screenReaderFocusable

true if the node is a focusable unit for screen readers, false otherwise.

setScrollable

Added in 1.1.0
public void setScrollable(boolean scrollable)

Sets if the node is scrollable.

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

Parameters
boolean scrollable

True if the node is scrollable, false otherwise.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setSelected

Added in 1.1.0
public void setSelected(boolean selected)

Sets whether this node is selected.

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

Parameters
boolean selected

True if the node is selected.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setShowingHintText

Added in 1.1.0
public void setShowingHintText(boolean showingHintText)

Sets whether the node's text represents a hint for the user to enter text. It should only be true if the node has editable text.

This method has no effect below API 19

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

Parameters
boolean showingHintText

true if the text in the node represents a hint to the user, false otherwise.

setSource

Added in 1.1.0
public void setSource(View source)

Sets the source.

Parameters
View source

The info source.

setSource

Added in 1.1.0
public void setSource(View root, int virtualDescendantId)

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 android.accessibilityservice.AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

This method is not supported on devices running API level <16 since the platform did not support virtual descendants of real views.

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual descendant.

setStateDescription

Added in 1.5.0
public void setStateDescription(@Nullable CharSequence stateDescription)

Sets the state description of this node.

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

Parameters
@Nullable CharSequence stateDescription

the state description of this node.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setText

Added in 1.1.0
public void setText(CharSequence text)

Sets the text of this node.

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

Parameters
CharSequence text

The text.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setTextEntryKey

Added in 1.1.0
public void setTextEntryKey(boolean isTextEntryKey)

Sets whether the node represents a text entry key that is part of a keyboard or keypad.

This method has no effect below API 19

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

Parameters
boolean isTextEntryKey

true if the node is a text entry key, false otherwise.

setTextSelectable

Added in 1.9.0
public void setTextSelectable(boolean selectableText)

Sets if the node has selectable text.

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

Compatibility:

  • Api <19: Does not operate.
Parameters
boolean selectableText

True if the node has selectable text, false otherwise.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setTextSelection

Added in 1.1.0
public void setTextSelection(int start, int end)

Sets the text selection start and end.

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

Parameters
int start

The text selection start.

int end

The text selection end.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setTooltipText

Added in 1.1.0
public void setTooltipText(@Nullable CharSequence tooltipText)

Sets the tooltip text of this node.

This method has no effect below API 19

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

Parameters
@Nullable CharSequence tooltipText

The tooltip text.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setTouchDelegateInfo

Added in 1.2.0
public void setTouchDelegateInfo(
    @NonNull AccessibilityNodeInfoCompat.TouchDelegateInfoCompat delegatedInfo
)

Set touch delegate info if the represented view has a android.view.TouchDelegate.

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

Compatibility:

  • API <29: No-op
Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setTraversalAfter

Added in 1.1.0
public void setTraversalAfter(View view)

Sets the view whose node is visited after this one in accessibility traversal. A screen-reader must visit the content of the other node before the content of this one.

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

Parameters
View view

The previous view.

setTraversalAfter

Added in 1.1.0
public void setTraversalAfter(View root, int virtualDescendantId)

Sets the node after which this one is visited in accessibility traversal. A screen-reader must visit the content of the other node before the content of this one. If virtualDescendantId equals to NO_ID the root is set as the predecessor.

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 android.accessibilityservice.AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual descendant.

setTraversalBefore

Added in 1.1.0
public void setTraversalBefore(View view)

Sets the view before whose node this one should be visited during traversal. A screen-reader must visit the content of this node before the content of the one it precedes.

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

Parameters
View view

The view providing the preceding node.

setTraversalBefore

Added in 1.1.0
public void setTraversalBefore(View root, int virtualDescendantId)

Sets the node before which this one is visited during traversal. A screen-reader must visit the content of this node before the content of the one it precedes. The successor is a virtual descendant of the given root. If virtualDescendantId equals to NO_ID the root is set as the successor.

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 android.accessibilityservice.AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
View root

The root of the virtual subtree.

int virtualDescendantId

The id of the virtual descendant.

setUniqueId

Added in 1.9.0
public void setUniqueId(@Nullable String uniqueId)

Sets the unique id of this node.

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

Parameters
@Nullable String uniqueId

the unique id of this node.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setViewIdResourceName

Added in 1.1.0
public void setViewIdResourceName(String viewId)

Sets the fully qualified resource name of the source view's id.

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

Parameters
String viewId

The id resource name.

setVisibleToUser

Added in 1.1.0
public void setVisibleToUser(boolean visibleToUser)

Sets whether this node is visible to the user.

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

Parameters
boolean visibleToUser

Whether the node is visible to the user.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

toString

public @NonNull String toString()

wrap

Added in 1.1.0
public static AccessibilityNodeInfoCompat wrap(@NonNull AccessibilityNodeInfo info)

Creates a new instance wrapping an android.view.accessibility.AccessibilityNodeInfo.

Parameters
@NonNull AccessibilityNodeInfo info

The info.