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 for building CollectionInfoCompat objects.

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.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.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_IN_WINDOW_KEY = "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_IN_WINDOW_KEY"

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

static final String
EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY = "android.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 a node representing a form field requires input or selection.

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
setFieldRequired(boolean required)

Sets whether this node represents a form field that requires input or selection.

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.