AccessibilityNodeInfo api文档

 https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo 

AccessibilityNodeInfo

Kotlin |Java

public class AccessibilityNodeInfo
extends Object implements Parcelable

java.lang.Object
   ↳android.view.accessibility.AccessibilityNodeInfo


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

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

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

Developer Guides

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

See also:

Summary

Nested classes

classAccessibilityNodeInfo.AccessibilityAction

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

classAccessibilityNodeInfo.CollectionInfo

Class with information if a node is a collection. 

classAccessibilityNodeInfo.CollectionItemInfo

Class with information if a node is a collection item. 

classAccessibilityNodeInfo.ExtraRenderingInfo

Class with information of a view useful to evaluate accessibility needs. 

classAccessibilityNodeInfo.RangeInfo

Class with information if a node is a range. 

classAccessibilityNodeInfo.TouchDelegateInfo

Class with information of touch delegated views and regions from TouchDelegate for the AccessibilityNodeInfo

Constants

intACTION_ACCESSIBILITY_FOCUS

Action that gives accessibility focus to the node.

StringACTION_ARGUMENT_COLUMN_INT

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

StringACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

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

StringACTION_ARGUMENT_HTML_ELEMENT_STRING

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

StringACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT

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

StringACTION_ARGUMENT_MOVE_WINDOW_X

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

StringACTION_ARGUMENT_MOVE_WINDOW_Y

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

StringACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT

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

StringACTION_ARGUMENT_PROGRESS_VALUE

Argument for specifying the progress value to set.

StringACTION_ARGUMENT_ROW_INT

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

StringACTION_ARGUMENT_SELECTION_END_INT

Argument for specifying the selection end.

StringACTION_ARGUMENT_SELECTION_START_INT

Argument for specifying the selection start.

StringACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

Argument for specifying the text content to set.

intACTION_CLEAR_ACCESSIBILITY_FOCUS

Action that clears accessibility focus of the node.

intACTION_CLEAR_FOCUS

Action that clears input focus of the node.

intACTION_CLEAR_SELECTION

Action that deselects the node.

intACTION_CLICK

Action that clicks on the node info.

intACTION_COLLAPSE

Action to collapse an expandable node.

intACTION_COPY

Action to copy the current selection to the clipboard.

intACTION_CUT

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

intACTION_DISMISS

Action to dismiss a dismissable node.

intACTION_EXPAND

Action to expand an expandable node.

intACTION_FOCUS

Action that gives input focus to the node.

intACTION_LONG_CLICK

Action that long clicks on the node.

intACTION_NEXT_AT_MOVEMENT_GRANULARITY

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

intACTION_NEXT_HTML_ELEMENT

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

intACTION_PASTE

Action to paste the current clipboard content.

intACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

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

intACTION_PREVIOUS_HTML_ELEMENT

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

intACTION_SCROLL_BACKWARD

Action to scroll the node content backward.

intACTION_SCROLL_FORWARD

Action to scroll the node content forward.

intACTION_SELECT

Action that selects the node.

intACTION_SET_SELECTION

Action to set the selection.

intACTION_SET_TEXT

Action that sets the text of the node.

StringEXTRA_DATA_RENDERING_INFO_KEY

Key used to request extra data for the rendering information.

StringEXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH

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

intEXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH

The maximum allowed length of the requested text location data.

StringEXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX

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

StringEXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY

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

intFLAG_PREFETCH_ANCESTORS

Prefetching strategy that prefetches the ancestors of the requested node.

intFLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST

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

intFLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST

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

intFLAG_PREFETCH_DESCENDANTS_HYBRID

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

intFLAG_PREFETCH_SIBLINGS

Prefetching strategy that prefetches the siblings of the requested node.

intFLAG_PREFETCH_UNINTERRUPTIBLE

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

intFOCUS_ACCESSIBILITY

The accessibility focus.

intFOCUS_INPUT

The input focus.

intMAX_NUMBER_OF_PREFETCHED_NODES

Maximum batch size of prefetched nodes for a request.

intMOVEMENT_GRANULARITY_CHARACTER

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

intMOVEMENT_GRANULARITY_LINE

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

intMOVEMENT_GRANULARITY_PAGE

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

intMOVEMENT_GRANULARITY_PARAGRAPH

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

intMOVEMENT_GRANULARITY_WORD

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

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<AccessibilityNodeInfo>CREATOR

Public constructors

AccessibilityNodeInfo()

Creates a new AccessibilityNodeInfo.

AccessibilityNodeInfo(View source)

Creates a new AccessibilityNodeInfo with the given source.

AccessibilityNodeInfo(View root, int virtualDescendantId)

Creates a new AccessibilityNodeInfo with the given source.

AccessibilityNodeInfo(AccessibilityNodeInfo info)

Copy constructor.

Public methods

voidaddAction(int action)

This method was deprecated in API level 21. This has been deprecated for addAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction)

voidaddAction(AccessibilityNodeInfo.AccessibilityAction action)

Adds an action that can be performed on the node.

voidaddChild(View root, int virtualDescendantId)

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

voidaddChild(View child)

Adds a child.

booleancanOpenPopup()

Gets if this node opens a popup or a dialog.

intdescribeContents()

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

booleanequals(Object object)

Indicates whether some other object is "equal to" this one.

List<AccessibilityNodeInfo>findAccessibilityNodeInfosByText(String text)

Finds AccessibilityNodeInfos by text.

List<AccessibilityNodeInfo>findAccessibilityNodeInfosByViewId(String viewId)

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

AccessibilityNodeInfofindFocus(int focus)

Find the view that has the specified focus type.

AccessibilityNodeInfofocusSearch(int direction)

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

List<AccessibilityNodeInfo.AccessibilityAction>getActionList()

Gets the actions that can be performed on the node.

intgetActions()

This method was deprecated in API level 21. Use getActionList().

List<String>getAvailableExtraData()

Get the extra data available for this node.

voidgetBoundsInParent(Rect outBounds)

This method was deprecated in API level 29. Use getBoundsInScreen(android.graphics.Rect) instead.

voidgetBoundsInScreen(Rect outBounds)

Gets the node bounds in screen coordinates.

AccessibilityNodeInfogetChild(int index)

Get the child at given index.

AccessibilityNodeInfogetChild(int index, int prefetchingStrategy)

Get the child at given index.

intgetChildCount()

Gets the number of children.

CharSequencegetClassName()

Gets the class this node comes from.

AccessibilityNodeInfo.CollectionInfogetCollectionInfo()

Gets the collection info if the node is a collection.

AccessibilityNodeInfo.CollectionItemInfogetCollectionItemInfo()

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

CharSequencegetContentDescription()

Gets the content description of this node.

intgetDrawingOrder()

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

CharSequencegetError()

Gets the error text of this node.

AccessibilityNodeInfo.ExtraRenderingInfogetExtraRenderingInfo()

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

BundlegetExtras()

Gets an optional bundle with extra data.

CharSequencegetHintText()

Gets the hint text of this node.

intgetInputType()

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

AccessibilityNodeInfogetLabelFor()

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

AccessibilityNodeInfogetLabeledBy()

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

intgetLiveRegion()

Gets the node's live region mode.

intgetMaxTextLength()

Returns the maximum text length for this node.

intgetMovementGranularities()

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

CharSequencegetPackageName()

Gets the package this node comes from.

CharSequencegetPaneTitle()

Get the title of the pane represented by this node.

AccessibilityNodeInfogetParent()

Gets the parent.

AccessibilityNodeInfogetParent(int prefetchingStrategy)

Gets the parent.

AccessibilityNodeInfo.RangeInfogetRangeInfo()

Gets the range info if this node is a range.

CharSequencegetStateDescription()

Get the state description of this node.

CharSequencegetText()

Gets the text of this node.

intgetTextSelectionEnd()

Gets the text selection end if text is selected.

intgetTextSelectionStart()

Gets the text selection start or the cursor position.

CharSequencegetTooltipText()

Gets the tooltip text of this node.

AccessibilityNodeInfo.TouchDelegateInfogetTouchDelegateInfo()

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

AccessibilityNodeInfogetTraversalAfter()

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

AccessibilityNodeInfogetTraversalBefore()

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

StringgetUniqueId()

Gets the unique id of the node.

StringgetViewIdResourceName()

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

AccessibilityWindowInfogetWindow()

Gets the window to which this node belongs.

intgetWindowId()

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

inthashCode()

Returns a hash code value for the object.

booleanisAccessibilityFocused()

Gets whether this node is accessibility focused.

booleanisCheckable()

Gets whether this node is checkable.

booleanisChecked()

Gets whether this node is checked.

booleanisClickable()

Gets whether this node is clickable.

booleanisContentInvalid()

Gets if the content of this node is invalid.

booleanisContextClickable()

Gets whether this node is context clickable.

booleanisDismissable()

Gets if the node can be dismissed.

booleanisEditable()

Gets if the node is editable.

booleanisEnabled()

Gets whether this node is enabled.

booleanisFocusable()

Gets whether this node is focusable.

booleanisFocused()

Gets whether this node is focused.

booleanisHeading()

Returns whether node represents a heading.

booleanisImportantForAccessibility()

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

booleanisLongClickable()

Gets whether this node is long clickable.

booleanisMultiLine()

Gets if the node is a multi line editable text.

booleanisPassword()

Gets whether this node is a password.

booleanisScreenReaderFocusable()

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

booleanisScrollable()

Gets if the node is scrollable.

booleanisSelected()

Gets whether this node is selected.

booleanisShowingHintText()

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

booleanisTextEntryKey()

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

booleanisTextSelectable()

Gets if the node has selectable text.

booleanisVisibleToUser()

Gets whether this node is visible to the user.

static AccessibilityNodeInfoobtain(View root, int virtualDescendantId)

This method was deprecated in API level Tiramisu. Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.View, int) instead.

static AccessibilityNodeInfoobtain(AccessibilityNodeInfo info)

This method was deprecated in API level Tiramisu. Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) instead.

static AccessibilityNodeInfoobtain()

This method was deprecated in API level Tiramisu. Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo() instead.

static AccessibilityNodeInfoobtain(View source)

This method was deprecated in API level Tiramisu. Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.View) instead.

booleanperformAction(int action, Bundle arguments)

Performs an action on the node.

booleanperformAction(int action)

Performs an action on the node.

voidrecycle()

This method was deprecated in API level Tiramisu. Object pooling has been discontinued. Calling this function now will have no effect.

booleanrefresh()

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

booleanrefreshWithExtraData(String extraDataKey, Bundle args)

Refreshes this info with the latest state of the view it represents, and request new data be added by the View.

booleanremoveAction(AccessibilityNodeInfo.AccessibilityAction action)

Removes an action that can be performed on the node.

voidremoveAction(int action)

This method was deprecated in API level 21. Use removeAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction)

booleanremoveChild(View root, int virtualDescendantId)

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

booleanremoveChild(View child)

Removes a child.

voidsetAccessibilityFocused(boolean focused)

Sets whether this node is accessibility focused.

voidsetAvailableExtraData(List<String> extraDataKeys)

Set the extra data available for this node.

voidsetBoundsInParent(Rect bounds)

This method was deprecated in API level 29. Accessibility services should not care about these bounds.

voidsetBoundsInScreen(Rect bounds)

Sets the node bounds in screen coordinates.

voidsetCanOpenPopup(boolean opensPopup)

Sets if this node opens a popup or a dialog.

voidsetCheckable(boolean checkable)

Sets whether this node is checkable.

voidsetChecked(boolean checked)

Sets whether this node is checked.

voidsetClassName(CharSequence className)

Sets the class this node comes from.

voidsetClickable(boolean clickable)

Sets whether this node is clickable.

voidsetCollectionInfo(AccessibilityNodeInfo.CollectionInfo collectionInfo)

Sets the collection info if the node is a collection.

voidsetCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo collectionItemInfo)

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

voidsetContentDescription(CharSequence contentDescription)

Sets the content description of this node.

voidsetContentInvalid(boolean contentInvalid)

Sets if the content of this node is invalid.

voidsetContextClickable(boolean contextClickable)

Sets whether this node is context clickable.

voidsetDismissable(boolean dismissable)

Sets if the node can be dismissed.

voidsetDrawingOrder(int drawingOrderInParent)

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

voidsetEditable(boolean editable)

Sets whether this node is editable.

voidsetEnabled(boolean enabled)

Sets whether this node is enabled.

voidsetError(CharSequence error)

Sets the error text of this node.

voidsetFocusable(boolean focusable)

Sets whether this node is focusable.

voidsetFocused(boolean focused)

Sets whether this node is focused.

voidsetHeading(boolean isHeading)

Sets whether the node represents a heading.

voidsetHintText(CharSequence hintText)

Sets the hint text of this node.

voidsetImportantForAccessibility(boolean important)

Sets whether the node is considered important for accessibility.

voidsetInputType(int inputType)

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

voidsetLabelFor(View root, int virtualDescendantId)

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

voidsetLabelFor(View labeled)

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

voidsetLabeledBy(View label)

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

voidsetLabeledBy(View root, int virtualDescendantId)

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

voidsetLiveRegion(int mode)

Sets the node's live region mode.

voidsetLongClickable(boolean longClickable)

Sets whether this node is long clickable.

voidsetMaxTextLength(int max)

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

voidsetMovementGranularities(int granularities)

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

voidsetMultiLine(boolean multiLine)

Sets if the node is a multi line editable text.

voidsetPackageName(CharSequence packageName)

Sets the package this node comes from.

voidsetPaneTitle(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.

voidsetParent(View root, int virtualDescendantId)

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

voidsetParent(View parent)

Sets the parent.

voidsetPassword(boolean password)

Sets whether this node is a password.

voidsetRangeInfo(AccessibilityNodeInfo.RangeInfo rangeInfo)

Sets the range info if this node is a range.

voidsetScreenReaderFocusable(boolean screenReaderFocusable)

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

voidsetScrollable(boolean scrollable)

Sets if the node is scrollable.

voidsetSelected(boolean selected)

Sets whether this node is selected.

voidsetShowingHintText(boolean showingHintText)

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

voidsetSource(View source)

Sets the source.

voidsetSource(View root, int virtualDescendantId)

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

voidsetStateDescription(CharSequence stateDescription)

Sets the state description of this node.

voidsetText(CharSequence text)

Sets the text of this node.

voidsetTextEntryKey(boolean isTextEntryKey)

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

voidsetTextSelectable(boolean selectableText)

Sets if the node has selectable text.

voidsetTextSelection(int start, int end)

Sets the text selection start and end.

voidsetTooltipText(CharSequence tooltipText)

Sets the tooltip text of this node.

voidsetTouchDelegateInfo(AccessibilityNodeInfo.TouchDelegateInfo delegatedInfo)

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

voidsetTraversalAfter(View view)

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

voidsetTraversalAfter(View root, int virtualDescendantId)

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

voidsetTraversalBefore(View view)

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

voidsetTraversalBefore(View root, int virtualDescendantId)

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

voidsetUniqueId(String uniqueId)

Sets the unique id to act as a key to identify the node.

voidsetViewIdResourceName(String viewIdResName)

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

voidsetVisibleToUser(boolean visibleToUser)

Sets whether this node is visible to the user.

StringtoString()

Returns a string representation of the object.

voidwriteToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

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

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

ACTION_ACCESSIBILITY_FOCUS

Added in API level 16

public static final int ACTION_ACCESSIBILITY_FOCUS

Action that gives accessibility focus to the node.

Constant Value: 64 (0x00000040)

ACTION_ARGUMENT_COLUMN_INT

Added in API level 23

public static final String ACTION_ARGUMENT_COLUMN_INT

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

Type: int
Actions:

See also:

Constant Value: "android.view.accessibility.action.ARGUMENT_COLUMN_INT"

ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

Added in API level 18

public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN

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

Type: boolean
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"

ACTION_ARGUMENT_HTML_ELEMENT_STRING

Added in API level 16

public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING

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

Type: String
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_HTML_ELEMENT_STRING"

ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT

Added in API level 16

public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT

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

Type: int
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"

ACTION_ARGUMENT_MOVE_WINDOW_X

Added in API level 26

public static final String ACTION_ARGUMENT_MOVE_WINDOW_X

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

Type: int
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_MOVE_WINDOW_X"

ACTION_ARGUMENT_MOVE_WINDOW_Y

Added in API level 26

public static final String ACTION_ARGUMENT_MOVE_WINDOW_Y

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

Type: int
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_MOVE_WINDOW_Y"

ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT

Added in API level 30

public static final String ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT

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

Type: int
Actions:

See also:

Constant Value: "android.view.accessibility.action.ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT"

ACTION_ARGUMENT_PROGRESS_VALUE

Added in API level 24

public static final String ACTION_ARGUMENT_PROGRESS_VALUE

Argument for specifying the progress value to set.

Type: float
Actions:

See also:

Constant Value: "android.view.accessibility.action.ARGUMENT_PROGRESS_VALUE"

ACTION_ARGUMENT_ROW_INT

Added in API level 23

public static final String ACTION_ARGUMENT_ROW_INT

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

Type: int
Actions:

See also:

Constant Value: "android.view.accessibility.action.ARGUMENT_ROW_INT"

ACTION_ARGUMENT_SELECTION_END_INT

Added in API level 18

public static final String ACTION_ARGUMENT_SELECTION_END_INT

Argument for specifying the selection end.

Type: int
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_SELECTION_END_INT"

ACTION_ARGUMENT_SELECTION_START_INT

Added in API level 18

public static final String ACTION_ARGUMENT_SELECTION_START_INT

Argument for specifying the selection start.

Type: int
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_SELECTION_START_INT"

ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

Added in API level 21

public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE

Argument for specifying the text content to set.

Type: CharSequence
Actions:

See also:

Constant Value: "ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"

ACTION_CLEAR_ACCESSIBILITY_FOCUS

Added in API level 16

public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS

Action that clears accessibility focus of the node.

Constant Value: 128 (0x00000080)

ACTION_CLEAR_FOCUS

Added in API level 14

public static final int ACTION_CLEAR_FOCUS

Action that clears input focus of the node.

Constant Value: 2 (0x00000002)

ACTION_CLEAR_SELECTION

Added in API level 14

public static final int ACTION_CLEAR_SELECTION

Action that deselects the node.

Constant Value: 8 (0x00000008)

ACTION_CLICK

Added in API level 16

public static final int ACTION_CLICK

Action that clicks on the node info. See AccessibilityAction#ACTION_CLICK

Constant Value: 16 (0x00000010)

ACTION_COLLAPSE

Added in API level 19

public static final int ACTION_COLLAPSE

Action to collapse an expandable node.

Constant Value: 524288 (0x00080000)

ACTION_COPY

Added in API level 18

public static final int ACTION_COPY

Action to copy the current selection to the clipboard.

Constant Value: 16384 (0x00004000)

ACTION_CUT

Added in API level 18

public static final int ACTION_CUT

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

Constant Value: 65536 (0x00010000)

ACTION_DISMISS

Added in API level 19

public static final int ACTION_DISMISS

Action to dismiss a dismissable node.

Constant Value: 1048576 (0x00100000)

ACTION_EXPAND

Added in API level 19

public static final int ACTION_EXPAND

Action to expand an expandable node.

Constant Value: 262144 (0x00040000)

ACTION_FOCUS

Added in API level 14

public static final int ACTION_FOCUS

Action that gives input focus to the node.

Constant Value: 1 (0x00000001)

ACTION_LONG_CLICK

Added in API level 16

public static final int ACTION_LONG_CLICK

Action that long clicks on the node.

It does not support coordinate information for anchoring.

Constant Value: 32 (0x00000020)

ACTION_NEXT_AT_MOVEMENT_GRANULARITY

Added in API level 16

public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY

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

Arguments: ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT<, ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: 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);

See also:

Constant Value: 256 (0x00000100)

ACTION_NEXT_HTML_ELEMENT

Added in API level 16

public static final int ACTION_NEXT_HTML_ELEMENT

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

Arguments: ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

 

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

Constant Value: 1024 (0x00000400)

ACTION_PASTE

Added in API level 18

public static final int ACTION_PASTE

Action to paste the current clipboard content.

Constant Value: 32768 (0x00008000)

ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Added in API level 16

public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

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

Arguments: ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT<, ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: 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);

See also:

Constant Value: 512 (0x00000200)

ACTION_PREVIOUS_HTML_ELEMENT

Added in API level 16

public static final int ACTION_PREVIOUS_HTML_ELEMENT

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

Arguments: ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

 

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

Constant Value: 2048 (0x00000800)

ACTION_SCROLL_BACKWARD

Added in API level 16

public static final int ACTION_SCROLL_BACKWARD

Action to scroll the node content backward.

Constant Value: 8192 (0x00002000)

ACTION_SCROLL_FORWARD

Added in API level 16

public static final int ACTION_SCROLL_FORWARD

Action to scroll the node content forward.

Constant Value: 4096 (0x00001000)

ACTION_SELECT

Added in API level 14

public static final int ACTION_SELECT

Action that selects the node.

Constant Value: 4 (0x00000004)

ACTION_SET_SELECTION

Added in API level 18

public static final int ACTION_SET_SELECTION

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

Arguments: ACTION_ARGUMENT_SELECTION_START_INTACTION_ARGUMENT_SELECTION_END_INT
Example:

 

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

See also:

Constant Value: 131072 (0x00020000)

ACTION_SET_TEXT

Added in API level 21

public static final int ACTION_SET_TEXT

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_CHARSEQUENCE
Example:

 

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

Constant Value: 2097152 (0x00200000)

EXTRA_DATA_RENDERING_INFO_KEY

Added in API level 30

public static final String EXTRA_DATA_RENDERING_INFO_KEY

Key used to request extra data for the rendering information. The key requests that a AccessibilityNodeInfo.ExtraRenderingInfo be added to this info. This request is made with refreshWithExtraData(java.lang.String, android.os.Bundle) without argument.

The data can be retrieved from the ExtraRenderingInfo returned by getExtraRenderingInfo() using ExtraRenderingInfo#getLayoutSizeExtraRenderingInfo#getTextSizeInPx() and ExtraRenderingInfo#getTextSizeUnit(). For layout params, it is supported by both TextView and ViewGroup. For text size and unit, it is only supported by TextView.

See also:

Constant Value: "android.view.accessibility.extra.DATA_RENDERING_INFO_KEY"

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH

Added in API level 26

public static final String 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.

See also:

Constant Value: "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH"

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH

Added in API level 31

public static final int EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_MAX_LENGTH

The maximum allowed length of the requested text location data.

Constant Value: 20000 (0x00004e20)

EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX

Added in API level 26

public static final String 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().

See also:

Constant Value: "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX"

EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY

Added in API level 26

public static final String 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 RectFs be added to the extras. This request is made with refreshWithExtraData(java.lang.String, android.os.Bundle). 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 Bundle#getParcelableArray(String). The RectF will be null for characters that either do not exist or are off the screen.

See also:

Constant Value: "android.view.accessibility.extra.DATA_TEXT_CHARACTER_LOCATION_KEY"

FLAG_PREFETCH_ANCESTORS

Added in Android Tiramisu

public static final int FLAG_PREFETCH_ANCESTORS

Prefetching strategy that prefetches the ancestors of the requested node.

Ancestors will be prefetched before siblings and descendants.

See also:

Constant Value: 1 (0x00000001)

FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST

Added in Android Tiramisu

public static final int FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST

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:

Constant Value: 16 (0x00000010)

FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST

Added in Android Tiramisu

public static final int FLAG_PREFETCH_DESCENDANTS_DEPTH_FIRST

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:

Constant Value: 8 (0x00000008)

FLAG_PREFETCH_DESCENDANTS_HYBRID

Added in Android Tiramisu

public static final int FLAG_PREFETCH_DESCENDANTS_HYBRID

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:

Constant Value: 4 (0x00000004)

FLAG_PREFETCH_SIBLINGS

Added in Android Tiramisu

public static final int FLAG_PREFETCH_SIBLINGS

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:

Constant Value: 2 (0x00000002)

FLAG_PREFETCH_UNINTERRUPTIBLE

Added in Android Tiramisu

public static final int FLAG_PREFETCH_UNINTERRUPTIBLE

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:

Constant Value: 32 (0x00000020)

FOCUS_ACCESSIBILITY

Added in API level 16

public static final int FOCUS_ACCESSIBILITY

The accessibility focus.

Constant Value: 2 (0x00000002)

FOCUS_INPUT

Added in API level 16

public static final int FOCUS_INPUT

The input focus.

Constant Value: 1 (0x00000001)

MAX_NUMBER_OF_PREFETCHED_NODES

Added in Android Tiramisu

public static final int MAX_NUMBER_OF_PREFETCHED_NODES

Maximum batch size of prefetched nodes for a request.

Constant Value: 50 (0x00000032)

MOVEMENT_GRANULARITY_CHARACTER

Added in API level 16

public static final int MOVEMENT_GRANULARITY_CHARACTER

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

Constant Value: 1 (0x00000001)

MOVEMENT_GRANULARITY_LINE

Added in API level 16

public static final int MOVEMENT_GRANULARITY_LINE

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

Constant Value: 4 (0x00000004)

MOVEMENT_GRANULARITY_PAGE

Added in API level 16

public static final int MOVEMENT_GRANULARITY_PAGE

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

Constant Value: 16 (0x00000010)

MOVEMENT_GRANULARITY_PARAGRAPH

Added in API level 16

public static final int MOVEMENT_GRANULARITY_PARAGRAPH

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

Constant Value: 8 (0x00000008)

MOVEMENT_GRANULARITY_WORD

Added in API level 16

public static final int MOVEMENT_GRANULARITY_WORD

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

Constant Value: 2 (0x00000002)

Fields

CREATOR

Added in API level 14

public static final Creator<AccessibilityNodeInfo> CREATOR

See also:

Public constructors

AccessibilityNodeInfo

Added in API level 30

public AccessibilityNodeInfo ()

Creates a new AccessibilityNodeInfo.

AccessibilityNodeInfo

Added in API level 30

public AccessibilityNodeInfo (View source)

Creates a new AccessibilityNodeInfo with the given source.

Parameters
sourceView: The source view. This value cannot be null.

AccessibilityNodeInfo

Added in API level 30

public AccessibilityNodeInfo (View root, 
                int virtualDescendantId)

Creates a new AccessibilityNodeInfo with the given source.

Parameters
rootView: The root of the virtual subtree. This value cannot be null.

virtualDescendantIdint: The id of the virtual descendant.

AccessibilityNodeInfo

Added in API level 30

public AccessibilityNodeInfo (AccessibilityNodeInfo info)

Copy constructor. Creates a new AccessibilityNodeInfo, and this new instance is initialized from the given info.

Parameters
infoAccessibilityNodeInfo: The other info. This value cannot be null.

Public methods

addAction

Added in API level 14
Deprecated in API level 21

public void addAction (int action)

This method was deprecated in API level 21.
This has been deprecated for addAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction)

Adds an action that can be performed on the node.

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

Parameters
actionint: The action.

Throws
IllegalStateExceptionIf called from an AccessibilityService.
IllegalArgumentExceptionIf the argument is not one of the standard actions.

addAction

Added in API level 21

public void addAction (AccessibilityNodeInfo.AccessibilityAction action)

Adds an action that can be performed on the node.

To add a standard action use the static constants on AccessibilityAction. To add a custom action create a new AccessibilityAction by passing in a resource id from your application as the action id and an optional label that describes the action. To override one of the standard actions use as the action id of a standard action id such as ACTION_CLICK and an optional label that describes the action.

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

Parameters
actionAccessibilityNodeInfo.AccessibilityAction: The action.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

addChild

Added in API level 16

public void addChild (View root, 
                int virtualDescendantId)

Adds a virtual child which is a descendant of the given root. If virtualDescendantId is View#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. Note that a view cannot be made its own child.

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual child.

addChild

Added in API level 14

public void addChild (View child)

Adds a child.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService. Note that a view cannot be made its own child.

Parameters
childView: The child.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

canOpenPopup

Added in API level 19

public boolean canOpenPopup ()

Gets if this node opens a popup or a dialog.

Returns
booleanIf the the node opens a popup.

describeContents

Added in API level 14

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
inta bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 14

public boolean equals (Object object)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value xx.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and yx.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values xy, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value xx.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objectObject: This value may be null.

Returns
booleantrue if this object is the same as the obj argument; false otherwise.

findAccessibilityNodeInfosByText

Added in API level 14

public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText (String text)

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

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

Note: If this view hierarchy has a SurfaceView embedding another view hierarchy via SurfaceView#setChildSurfacePackage, there is a limitation that this API won't be able to find the node for the view on the embedded view hierarchy. It's because views don't know about the embedded hierarchies. Instead, you could traverse all the children to find the node.

Parameters
textString: The searched text.

Returns
List<AccessibilityNodeInfo>A list of node info.

findAccessibilityNodeInfosByViewId

Added in API level 18

public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId (String viewId)

Finds AccessibilityNodeInfos 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: It is a client responsibility to recycle the received info by calling AccessibilityNodeInfo#recycle() to avoid creating of multiple instances.

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

Note: If this view hierarchy has a SurfaceView embedding another view hierarchy via SurfaceView#setChildSurfacePackage, there is a limitation that this API won't be able to find the node for the view on the embedded view hierarchy. It's because views don't know about the embedded hierarchies. Instead, you could traverse all the children to find the node.

Parameters
viewIdString: The fully qualified resource name of the view id to find. This value cannot be null.

Returns
List<AccessibilityNodeInfo>A list of node info.

findFocus

Added in API level 16

public AccessibilityNodeInfo findFocus (int focus)

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

Note: If this view hierarchy has a SurfaceView embedding another view hierarchy via SurfaceView#setChildSurfacePackage, there is a limitation that this API won't be able to find the node for the view on the embedded view hierarchy. It's because views don't know about the embedded hierarchies. Instead, you could traverse all the children to find the node. Or, use AccessibilityService#findFocus(int) for FOCUS_ACCESSIBILITY only since it has no such limitation.

Parameters
focusint: The focus to find. One of FOCUS_INPUT or FOCUS_ACCESSIBILITY.

Returns
AccessibilityNodeInfoThe node info of the focused view or null.

See also:

focusSearch

Added in API level 16

public AccessibilityNodeInfo focusSearch (int direction)

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

Note: If this view hierarchy has a SurfaceView embedding another view hierarchy via SurfaceView#setChildSurfacePackage, there is a limitation that this API won't be able to find the node for the view in the specified direction on the embedded view hierarchy. It's because views don't know about the embedded hierarchies. Instead, you could traverse all the children to find the node.

Parameters
directionint: The direction. Can be one of: View#FOCUS_DOWNView#FOCUS_UPView#FOCUS_LEFTView#FOCUS_RIGHTView#FOCUS_FORWARDView#FOCUS_BACKWARD.

Returns
AccessibilityNodeInfoThe node info for the view that can take accessibility focus.

getActionList

Added in API level 21

public List<AccessibilityNodeInfo.AccessibilityAction> getActionList ()

Gets the actions that can be performed on the node.

Returns
List<AccessibilityNodeInfo.AccessibilityAction>

getActions

Added in API level 14
Deprecated in API level 21

public int getActions ()

This method was deprecated in API level 21.
Use getActionList().

Gets the actions that can be performed on the node.

Returns
intThe bit mask of with actions.

See also:

getAvailableExtraData

Added in API level 26

public List<String> getAvailableExtraData ()

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(java.lang.String, android.os.Bundle).

Returns
List<String>An unmodifiable list of keys corresponding to extra data that can be requested.

See also:

getBoundsInParent

Added in API level 14
Deprecated in API level 29

public void getBoundsInParent (Rect outBounds)

This method was deprecated in API level 29.
Use getBoundsInScreen(android.graphics.Rect) instead.

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

When magnification is enabled, the bounds in parent are also scaled up by magnification scale. For example, it returns Rect(20, 20, 200, 200) for original bounds Rect(10, 10, 100, 100), when the magnification scale is 2.

Parameters
outBoundsRect: The output node bounds.

getBoundsInScreen

Added in API level 14

public void getBoundsInScreen (Rect outBounds)

Gets the node bounds in screen coordinates.

When magnification is enabled, the bounds in screen 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.

Parameters
outBoundsRect: The output node bounds.

getChild

Added in API level 14

public AccessibilityNodeInfo getChild (int index)

Get the child at given index.

Parameters
indexint: The child index.

Returns
AccessibilityNodeInfoThe child node.

Throws
IllegalStateExceptionIf called outside of an AccessibilityService.

getChild

Added in Android Tiramisu

public AccessibilityNodeInfo getChild (int index, 
                int prefetchingStrategy)

Get the child at given index.

Parameters
indexint: The child index.

prefetchingStrategyint: the prefetching strategy. Value is either 0 or a combination of FLAG_PREFETCH_ANCESTORSFLAG_PREFETCH_SIBLINGSFLAG_PREFETCH_DESCENDANTS_HYBRIDFLAG_PREFETCH_DESCENDANTS_DEPTH_FIRSTFLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST, and FLAG_PREFETCH_UNINTERRUPTIBLE

Returns
AccessibilityNodeInfoThe child node. This value may be null.

Throws
IllegalStateExceptionIf called outside of an AccessibilityService.

See also:

getChildCount

Added in API level 14

public int getChildCount ()

Gets the number of children.

Returns
intThe child count.

getClassName

Added in API level 14

public CharSequence getClassName ()

Gets the class this node comes from.

Returns
CharSequenceThe class name.

getCollectionInfo

Added in API level 19

public AccessibilityNodeInfo.CollectionInfo getCollectionInfo ()

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

Returns
AccessibilityNodeInfo.CollectionInfoThe collection info.

getCollectionItemInfo

Added in API level 19

public AccessibilityNodeInfo.CollectionItemInfo getCollectionItemInfo ()

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

Returns
AccessibilityNodeInfo.CollectionItemInfoThe collection item info.

getContentDescription

Added in API level 14

public CharSequence getContentDescription ()

Gets the content description of this node.

Returns
CharSequenceThe content description.

getDrawingOrder

Added in API level 24

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
intThe drawing position of the view corresponding to this node relative to its siblings.

getError

Added in API level 21

public CharSequence getError ()

Gets the error text of this node.

Returns
CharSequenceThe error text.

getExtraRenderingInfo

Added in API level 30

public 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.

Returns
AccessibilityNodeInfo.ExtraRenderingInfoThe extra rendering info. This value may be null.

See also:

getExtras

Added in API level 19

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
BundleThe bundle.

getHintText

Added in API level 26

public CharSequence getHintText ()

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

Returns
CharSequenceThe hint text.

getInputType

Added in API level 19

public int getInputType ()

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

Returns
intThe input type.

getLabelFor

Added in API level 17

public AccessibilityNodeInfo getLabelFor ()

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

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

Returns
AccessibilityNodeInfoThe labeled info.

getLabeledBy

Added in API level 17

public AccessibilityNodeInfo getLabeledBy ()

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

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

Returns
AccessibilityNodeInfoThe label.

getLiveRegion

Added in API level 19

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 View#ACCESSIBILITY_LIVE_REGION_POLITE.

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

Returns
intThe live region mode, or View#ACCESSIBILITY_LIVE_REGION_NONE if the view is not a live region.

See also:

getMaxTextLength

Added in API level 21

public int getMaxTextLength ()

Returns the maximum text length for this node.

Returns
intThe maximum text length, or -1 for no limit.

See also:

getMovementGranularities

Added in API level 16

public int getMovementGranularities ()

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

Returns
intThe bit mask with granularities.

getPackageName

Added in API level 14

public CharSequence getPackageName ()

Gets the package this node comes from.

Returns
CharSequenceThe package name.

getPaneTitle

Added in API level 28

public CharSequence getPaneTitle ()

Get the title of the pane represented by this node.

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

getParent

Added in API level 14

public AccessibilityNodeInfo getParent ()

Gets the parent.

Returns
AccessibilityNodeInfoThe parent.

getParent

Added in Android Tiramisu

public AccessibilityNodeInfo 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 AccessibilityNodeInfo#FLAG_PREFETCH_UNINTERRUPTIBLE.

Parameters
prefetchingStrategyint: the prefetching strategy. Value is either 0 or a combination of FLAG_PREFETCH_ANCESTORSFLAG_PREFETCH_SIBLINGSFLAG_PREFETCH_DESCENDANTS_HYBRIDFLAG_PREFETCH_DESCENDANTS_DEPTH_FIRSTFLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST, and FLAG_PREFETCH_UNINTERRUPTIBLE

Returns
AccessibilityNodeInfoThe parent. This value may be null.

Throws
IllegalStateExceptionIf called outside of an AccessibilityService.

See also:

getRangeInfo

Added in API level 19

public AccessibilityNodeInfo.RangeInfo getRangeInfo ()

Gets the range info if this node is a range.

Returns
AccessibilityNodeInfo.RangeInfoThe range.

getStateDescription

Added in API level 30

public CharSequence getStateDescription ()

Get the state description of this node.

Returns
CharSequencethe state description This value may be null.

getText

Added in API level 14

public CharSequence getText ()

Gets the text of this node.

Note: If the text contains ClickableSpans or URLSpans, these spans will have been replaced with ones whose ClickableSpan#onClick(View) can be called from an AccessibilityService. When called from a service, the View argument is ignored and the corresponding span will be found on the view that this AccessibilityNodeInfo represents and called with that view as its argument.

This treatment of ClickableSpans means that the text returned from this method may different slightly one passed to setText(java.lang.CharSequence), although they will be equivalent according to TextUtils#equals(CharSequence, CharSequence). The ClickableSpan#onClick(View) of any spans, however, will generally not work outside of an accessibility service.

Returns
CharSequenceThe text.

getTextSelectionEnd

Added in API level 18

public int getTextSelectionEnd ()

Gets the text selection end if text is selected.

If no text is selected, both this method and AccessibilityNodeInfo#getTextSelectionStart() return the same value: the current location of the cursor.

Returns
intThe text selection end, the cursor location if there is no selection, or -1 if there is no text selection and no cursor.

getTextSelectionStart

Added in API level 18

public int getTextSelectionStart ()

Gets the text selection start or the cursor position.

If no text is selected, both this method and AccessibilityNodeInfo#getTextSelectionEnd() return the same value: the current location of the cursor.

Returns
intThe text selection start, the cursor location if there is no selection, or -1 if there is no text selection and no cursor.

getTooltipText

Added in API level 28

public CharSequence getTooltipText ()

Gets the tooltip text of this node.

Returns
CharSequenceThe tooltip text. This value may be null.

getTouchDelegateInfo

Added in API level 29

public AccessibilityNodeInfo.TouchDelegateInfo getTouchDelegateInfo ()

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

Returns
AccessibilityNodeInfo.TouchDelegateInfoTouchDelegateInfo or null if there are no touch delegates.

getTraversalAfter

Added in API level 22

public AccessibilityNodeInfo 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
AccessibilityNodeInfoThe succeeding node if such or null.

See also:

getTraversalBefore

Added in API level 22

public AccessibilityNodeInfo 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
AccessibilityNodeInfoThe succeeding node if such or null.

See also:

getUniqueId

Added in Android Tiramisu

public String getUniqueId ()

Gets the unique id of the node.

Returns
StringThe unique id This value may be null.

getViewIdResourceName

Added in API level 18

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 AccessibilityNodeInfo the client has to set the AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS flag when configuring the AccessibilityService.

Returns
StringThe id resource name.

getWindow

Added in API level 21

public AccessibilityWindowInfo getWindow ()

Gets the window to which this node belongs.

Returns
AccessibilityWindowInfoThe window.

See also:

getWindowId

Added in API level 14

public int getWindowId ()

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

Returns
intThe window id.

hashCode

Added in API level 14

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
inta hash code value for this object.

isAccessibilityFocused

Added in API level 16

public boolean isAccessibilityFocused ()

Gets whether this node is accessibility focused.

Returns
booleanTrue if the node is accessibility focused.

isCheckable

Added in API level 14

public boolean isCheckable ()

Gets whether this node is checkable.

Returns
booleanTrue if the node is checkable.

isChecked

Added in API level 14

public boolean isChecked ()

Gets whether this node is checked.

Returns
booleanTrue if the node is checked.

isClickable

Added in API level 14

public boolean isClickable ()

Gets whether this node is clickable.

Returns
booleanTrue if the node is clickable.

isContentInvalid

Added in API level 19

public boolean isContentInvalid ()

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

Returns
booleanIf the node content is invalid.

isContextClickable

Added in API level 23

public boolean isContextClickable ()

Gets whether this node is context clickable.

Returns
booleanTrue if the node is context clickable.

isDismissable

Added in API level 19

public boolean isDismissable ()

Gets if the node can be dismissed.

Returns
booleanIf the node can be dismissed.

isEditable

Added in API level 18

public boolean isEditable ()

Gets if the node is editable.

Returns
booleanTrue if the node is editable, false otherwise.

isEnabled

Added in API level 14

public boolean isEnabled ()

Gets whether this node is enabled.

Returns
booleanTrue if the node is enabled.

isFocusable

Added in API level 14

public boolean isFocusable ()

Gets whether this node is focusable.

Returns
booleanTrue if the node is focusable.

isFocused

Added in API level 14

public boolean isFocused ()

Gets whether this node is focused.

Returns
booleanTrue if the node is focused.

isHeading

Added in API level 28

public boolean isHeading ()

Returns whether node represents a heading.

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

Returns
booleantrue if the node is a heading, false otherwise.

isImportantForAccessibility

Added in API level 24

public boolean isImportantForAccessibility ()

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

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

See also:

isLongClickable

Added in API level 14

public boolean isLongClickable ()

Gets whether this node is long clickable.

Returns
booleanTrue if the node is long clickable.

isMultiLine

Added in API level 19

public boolean isMultiLine ()

Gets if the node is a multi line editable text.

Returns
booleanTrue if the node is multi line.

isPassword

Added in API level 14

public boolean isPassword ()

Gets whether this node is a password.

Returns
booleanTrue if the node is a password.

isScreenReaderFocusable

Added in API level 28

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
booleantrue if the node is specifically marked as a focusable unit for screen readers, false otherwise.

See also:

isScrollable

Added in API level 14

public boolean isScrollable ()

Gets if the node is scrollable.

Returns
booleanTrue if the node is scrollable, false otherwise.

isSelected

Added in API level 14

public boolean isSelected ()

Gets whether this node is selected.

Returns
booleanTrue if the node is selected.

isShowingHintText

Added in API level 26

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
booleantrue if the text in the node represents a hint to the user, false otherwise.

isTextEntryKey

Added in API level 29

public boolean isTextEntryKey ()

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

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

isTextSelectable

Added in Android Tiramisu

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.

Returns
booleanTrue if the node has selectable text.

See also:

isVisibleToUser

Added in API level 16

public boolean isVisibleToUser ()

Gets whether this node is visible to the user.

Between API 16 and API 29, this method may incorrectly return false when magnification is enabled. On other versions, a node is considered visible even if it is not on the screen because magnification is active.

Returns
booleanWhether the node is visible to the user.

obtain

Added in API level 16
Deprecated in API level Tiramisu

public static AccessibilityNodeInfo obtain (View root, 
                int virtualDescendantId)

This method was deprecated in API level Tiramisu.
Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.View, int) instead.

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

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual descendant.

Returns
AccessibilityNodeInfoAn instance.

See also:

obtain

Added in API level 14
Deprecated in API level Tiramisu

public static AccessibilityNodeInfo obtain (AccessibilityNodeInfo info)

This method was deprecated in API level Tiramisu.
Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) instead.

Instantiates a new AccessibilityNodeInfo initialized from the given info.

Parameters
infoAccessibilityNodeInfo: The other info.

Returns
AccessibilityNodeInfoAn instance.

obtain

Added in API level 14
Deprecated in API level Tiramisu

public static AccessibilityNodeInfo obtain ()

This method was deprecated in API level Tiramisu.
Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo() instead.

Instantiates a new AccessibilityNodeInfo.

Returns
AccessibilityNodeInfoAn instance.

obtain

Added in API level 14
Deprecated in API level Tiramisu

public static AccessibilityNodeInfo obtain (View source)

This method was deprecated in API level Tiramisu.
Object pooling has been discontinued. Create a new instance using the constructor AccessibilityNodeInfo(android.view.View) instead.

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

Parameters
sourceView: The source view.

Returns
AccessibilityNodeInfoAn instance.

See also:

performAction

Added in API level 16

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 AccessibilityService.

Parameters
actionint: The action to perform.

argumentsBundle: A bundle with additional arguments.

Returns
booleanTrue if the action was performed.

Throws
IllegalStateExceptionIf called outside of an AccessibilityService.

performAction

Added in API level 14

public boolean performAction (int action)

Performs an action on the node.

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

Parameters
actionint: The action to perform.

Returns
booleanTrue if the action was performed.

Throws
IllegalStateExceptionIf called outside of an AccessibilityService.

recycle

Added in API level 14
Deprecated in API level Tiramisu

public void recycle ()

This method was deprecated in API level Tiramisu.
Object pooling has been discontinued. Calling this function now will have no effect.

Would previously return an instance back to be reused.

refresh

Added in API level 18

public boolean refresh ()

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

Returns
booleantrue if the refresh succeeded. false if the View represented by this node is no longer in the view tree (and thus this node is obsolete and should be recycled).

refreshWithExtraData

Added in API level 26

public boolean refreshWithExtraData (String extraDataKey, 
                Bundle args)

Refreshes this info with the latest state of the view it represents, and request new data be added by the View.

Parameters
extraDataKeyString: The extra data requested. Data that must be requested with this mechanism is generally expensive to retrieve, so should only be requested when needed. See EXTRA_DATA_RENDERING_INFO_KEYEXTRA_DATA_TEXT_CHARACTER_LOCATION_KEYgetAvailableExtraData() and getExtraRenderingInfo().

argsBundle: A bundle of arguments for the request. These depend on the particular request.

Returns
booleantrue if the refresh succeeded. false if the View represented by this node is no longer in the view tree (and thus this node is obsolete and should be recycled).

removeAction

Added in API level 21

public boolean removeAction (AccessibilityNodeInfo.AccessibilityAction 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 AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters
actionAccessibilityNodeInfo.AccessibilityAction: The action to be removed.

Returns
booleanThe action removed from the list of actions.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

removeAction

Added in API level 21
Deprecated in API level 21

public void removeAction (int action)

This method was deprecated in API level 21.
Use removeAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction)

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

Parameters
actionint: The action to be removed.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

removeChild

Added in API level 21

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
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual child.

Returns
booleantrue if the child was present

See also:

removeChild

Added in API level 21

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

Parameters
childView: The child.

Returns
booleantrue if the child was present

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setAccessibilityFocused

Added in API level 16

public void setAccessibilityFocused (boolean focused)

Sets whether this node is accessibility focused.

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

Parameters
focusedboolean: True if the node is accessibility focused.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setAvailableExtraData

Added in API level 26

public void setAvailableExtraData (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 View#addExtraDataToAccessibilityNodeInfo(AccessibilityNodeInfo, String, Bundle).

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

Parameters
extraDataKeysList: A list of types of extra data that are available.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

See also:

setBoundsInParent

Added in API level 14
Deprecated in API level 29

public void setBoundsInParent (Rect bounds)

This method was deprecated in API level 29.
Accessibility services should not care about these bounds.

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

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

Parameters
boundsRect: The node bounds.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setBoundsInScreen

Added in API level 14

public void setBoundsInScreen (Rect bounds)

Sets the node bounds in screen coordinates.

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

Parameters
boundsRect: The node bounds.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setCanOpenPopup

Added in API level 19

public void setCanOpenPopup (boolean opensPopup)

Sets if this node opens a popup or a dialog.

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

Parameters
opensPopupboolean: If the the node opens a popup.

setCheckable

Added in API level 14

public void setCheckable (boolean checkable)

Sets whether this node is checkable.

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

Parameters
checkableboolean: True if the node is checkable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setChecked

Added in API level 14

public void setChecked (boolean checked)

Sets whether this node is checked.

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

Parameters
checkedboolean: True if the node is checked.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setClassName

Added in API level 14

public void setClassName (CharSequence className)

Sets the class this node comes from.

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

Parameters
classNameCharSequence: The class name.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setClickable

Added in API level 14

public void setClickable (boolean clickable)

Sets whether this node is clickable.

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

Parameters
clickableboolean: True if the node is clickable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setCollectionInfo

Added in API level 19

public void setCollectionInfo (AccessibilityNodeInfo.CollectionInfo collectionInfo)

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

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

Parameters
collectionInfoAccessibilityNodeInfo.CollectionInfo: The collection info.

setCollectionItemInfo

Added in API level 19

public void setCollectionItemInfo (AccessibilityNodeInfo.CollectionItemInfo collectionItemInfo)

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

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

Parameters
collectionItemInfoAccessibilityNodeInfo.CollectionItemInfo

setContentDescription

Added in API level 14

public void setContentDescription (CharSequence contentDescription)

Sets the content description of this node.

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

Parameters
contentDescriptionCharSequence: The content description.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setContentInvalid

Added in API level 19

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

Parameters
contentInvalidboolean: If the node content is invalid.

setContextClickable

Added in API level 23

public void setContextClickable (boolean contextClickable)

Sets whether this node is context clickable.

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

Parameters
contextClickableboolean: True if the node is context clickable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setDismissable

Added in API level 19

public void setDismissable (boolean dismissable)

Sets if the node can be dismissed.

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

Parameters
dismissableboolean: If the node can be dismissed.

setDrawingOrder

Added in API level 24

public void setDrawingOrder (int drawingOrderInParent)

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

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

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setEditable

Added in API level 18

public void setEditable (boolean editable)

Sets whether this node is editable.

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

Parameters
editableboolean: True if the node is editable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setEnabled

Added in API level 14

public void setEnabled (boolean enabled)

Sets whether this node is enabled.

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

Parameters
enabledboolean: True if the node is enabled.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setError

Added in API level 21

public void setError (CharSequence error)

Sets the error text of this node.

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

Parameters
errorCharSequence: The error text.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setFocusable

Added in API level 14

public void setFocusable (boolean focusable)

Sets whether this node is focusable.

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

Parameters
focusableboolean: True if the node is focusable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setFocused

Added in API level 14

public void setFocused (boolean focused)

Sets whether this node is focused.

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

Parameters
focusedboolean: True if the node is focused.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setHeading

Added in API level 28

public void setHeading (boolean isHeading)

Sets whether the node represents a heading.

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

Parameters
isHeadingbooleantrue if the node is a heading, false otherwise.

setHintText

Added in API level 26

public void setHintText (CharSequence hintText)

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

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

Parameters
hintTextCharSequence: The hint text for this mode.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setImportantForAccessibility

Added in API level 24

public void setImportantForAccessibility (boolean important)

Sets whether the node is considered important for accessibility.

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

Parameters
importantbooleantrue if the node is considered important for accessibility, false otherwise

setInputType

Added in API level 19

public void setInputType (int inputType)

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

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

Parameters
inputTypeint: The input type.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setLabelFor

Added in API level 17

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 View#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.

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

Parameters
rootView: The root whose virtual descendant serves as a label.

virtualDescendantIdint: The id of the virtual descendant.

setLabelFor

Added in API level 17

public void setLabelFor (View labeled)

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

Parameters
labeledView: The view for which this info serves as a label.

setLabeledBy

Added in API level 17

public void setLabeledBy (View label)

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

Parameters
labelView: The view that labels this node's source.

setLabeledBy

Added in API level 17

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

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

virtualDescendantIdint: The id of the virtual descendant.

setLiveRegion

Added in API level 19

public void setLiveRegion (int mode)

Sets the node's live region mode.

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

Parameters
modeint: The live region mode, or View#ACCESSIBILITY_LIVE_REGION_NONE if the view is not a live region.

See also:

setLongClickable

Added in API level 14

public void setLongClickable (boolean longClickable)

Sets whether this node is long clickable.

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

Parameters
longClickableboolean: True if the node is long clickable.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setMaxTextLength

Added in API level 21

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

Parameters
maxint: The maximum text length.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

See also:

setMovementGranularities

Added in API level 16

public void setMovementGranularities (int granularities)

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

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

Parameters
granularitiesint: The bit mask with granularities.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setMultiLine

Added in API level 19

public void setMultiLine (boolean multiLine)

Sets if the node is a multi line editable text.

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

Parameters
multiLineboolean: True if the node is multi line.

setPackageName

Added in API level 14

public void setPackageName (CharSequence packageName)

Sets the package this node comes from.

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

Parameters
packageNameCharSequence: The package name.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setPaneTitle

Added in API level 28

public void setPaneTitle (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.

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

Parameters
paneTitleCharSequence: The title of the pane represented by this node. This value may be null.

setParent

Added in API level 16

public void setParent (View root, 
                int virtualDescendantId)

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

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

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

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual descendant.

setParent

Added in API level 14

public void setParent (View parent)

Sets the parent.

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

Parameters
parentView: The parent.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setPassword

Added in API level 14

public void setPassword (boolean password)

Sets whether this node is a password.

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

Parameters
passwordboolean: True if the node is a password.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setRangeInfo

Added in API level 19

public void setRangeInfo (AccessibilityNodeInfo.RangeInfo rangeInfo)

Sets the range info if this node is a range.

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

Parameters
rangeInfoAccessibilityNodeInfo.RangeInfo: The range info.

setScreenReaderFocusable

Added in API level 28

public void setScreenReaderFocusable (boolean screenReaderFocusable)

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

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

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

setScrollable

Added in API level 14

public void setScrollable (boolean scrollable)

Sets if the node is scrollable.

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

Parameters
scrollableboolean: True if the node is scrollable, false otherwise.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setSelected

Added in API level 14

public void setSelected (boolean selected)

Sets whether this node is selected.

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

Parameters
selectedboolean: True if the node is selected.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setShowingHintText

Added in API level 26

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.

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

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

setSource

Added in API level 14

public void setSource (View source)

Sets the source.

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

Parameters
sourceView: The info source.

setSource

Added in API level 16

public void setSource (View root, 
                int virtualDescendantId)

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

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

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

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual descendant.

setStateDescription

Added in API level 30

public void setStateDescription (CharSequence stateDescription)

Sets the state description of this node.

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

Parameters
stateDescriptionCharSequence: the state description of this node. This value may be null.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setText

Added in API level 14

public void setText (CharSequence text)

Sets the text of this node.

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

Parameters
textCharSequence: The text.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setTextEntryKey

Added in API level 29

public void setTextEntryKey (boolean isTextEntryKey)

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

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

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

setTextSelectable

Added in Android Tiramisu

public void setTextSelectable (boolean selectableText)

Sets if the node has selectable text.

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

Parameters
selectableTextboolean: True if the node has selectable text, false otherwise.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setTextSelection

Added in API level 18

public void setTextSelection (int start, 
                int end)

Sets the text selection start and end.

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

Parameters
startint: The text selection start.

endint: The text selection end.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setTooltipText

Added in API level 28

public void setTooltipText (CharSequence tooltipText)

Sets the tooltip text of this node.

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

Parameters
tooltipTextCharSequence: The tooltip text. This value may be null.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setTouchDelegateInfo

Added in API level 29

public void setTouchDelegateInfo (AccessibilityNodeInfo.TouchDelegateInfo delegatedInfo)

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

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

Parameters
delegatedInfoAccessibilityNodeInfo.TouchDelegateInfoTouchDelegateInfo returned from TouchDelegate#getTouchDelegateInfo(). This value cannot be null.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

setTraversalAfter

Added in API level 22

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

Parameters
viewView: The previous view.

See also:

setTraversalAfter

Added in API level 22

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

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual descendant.

setTraversalBefore

Added in API level 22

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

Parameters
viewView: The view providing the preceding node.

See also:

setTraversalBefore

Added in API level 22

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

Parameters
rootView: The root of the virtual subtree.

virtualDescendantIdint: The id of the virtual descendant.

setUniqueId

Added in Android Tiramisu

public void setUniqueId (String uniqueId)

Sets the unique id to act as a key to identify the node. If the node instance is replaced after refreshing the layout, calling this API to assign the same unique id to the new alike node can help accessibility service to identify it.

Parameters
uniqueIdString: The unique id that is associated with a visible node on the screen This value may be null.

setViewIdResourceName

Added in API level 18

public void setViewIdResourceName (String viewIdResName)

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

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

Parameters
viewIdResNameString: The id resource name.

setVisibleToUser

Added in API level 16

public void setVisibleToUser (boolean visibleToUser)

Sets whether this node is visible to the user.

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

Parameters
visibleToUserboolean: Whether the node is visible to the user.

Throws
IllegalStateExceptionIf called from an AccessibilityService.

toString

Added in API level 14

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

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

Returns
Stringa string representation of the object.

writeToParcel

Added in API level 14

public void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

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

Parameters
parcelParcel: The Parcel in which the object should be written. This value cannot be null.

flagsint: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值