public class AccessibilityNodeInfo extends Object implements Parcelable
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.
For more information about making applications accessible, read the Accessibility developer guide.
Modifier and Type | Class and Description |
---|---|
static class |
AccessibilityNodeInfo.AccessibilityAction
A class defining an action that can be performed on an
AccessibilityNodeInfo . |
static class |
AccessibilityNodeInfo.CollectionInfo
Class with information if a node is a collection.
|
static class |
AccessibilityNodeInfo.CollectionItemInfo
Class with information if a node is a collection item.
|
static class |
AccessibilityNodeInfo.RangeInfo
Class with information if a node is a range.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_ACCESSIBILITY_FOCUS
Action that gives accessibility focus to the node.
|
static String |
ACTION_ARGUMENT_COLUMN_INT
Argument for specifying the collection column to make visible on screen.
|
static String |
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Argument for whether when moving at granularity to extend the selection
or to move it otherwise.
|
static String |
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Argument for which HTML element to get moving to the next/previous HTML element.
|
static String |
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Argument for which movement granularity to be used when traversing the node text.
|
static String |
ACTION_ARGUMENT_PROGRESS_VALUE
Argument for specifying the progress value to set.
|
static String |
ACTION_ARGUMENT_ROW_INT
Argument for specifying the collection row to make visible on screen.
|
static String |
ACTION_ARGUMENT_SELECTION_END_INT
Argument for specifying the selection end.
|
static String |
ACTION_ARGUMENT_SELECTION_START_INT
Argument for specifying the selection start.
|
static String |
ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
Argument for specifying the text content to set.
|
static int |
ACTION_CLEAR_ACCESSIBILITY_FOCUS
Action that clears accessibility focus of the node.
|
static int |
ACTION_CLEAR_FOCUS
Action that clears input focus of the node.
|
static int |
ACTION_CLEAR_SELECTION
Action that deselects the node.
|
static int |
ACTION_CLICK
Action that clicks on the node info.
|
static int |
ACTION_COLLAPSE
Action to collapse an expandable node.
|
static int |
ACTION_COPY
Action to copy the current selection to the clipboard.
|
static int |
ACTION_CUT
Action to cut the current selection and place it to the clipboard.
|
static int |
ACTION_DISMISS
Action to dismiss a dismissable node.
|
static int |
ACTION_EXPAND
Action to expand an expandable node.
|
static int |
ACTION_FOCUS
Action that gives input focus to the node.
|
static int |
ACTION_LONG_CLICK
Action that long clicks on the node.
|
static 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.
|
static int |
ACTION_NEXT_HTML_ELEMENT
Action to move to the next HTML element of a given type.
|
static int |
ACTION_PASTE
Action to paste the current clipboard content.
|
static 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.
|
static int |
ACTION_PREVIOUS_HTML_ELEMENT
Action to move to the previous HTML element of a given type.
|
static int |
ACTION_SCROLL_BACKWARD
Action to scroll the node content backward.
|
static int |
ACTION_SCROLL_FORWARD
Action to scroll the node content forward.
|
static int |
ACTION_SELECT
Action that selects the node.
|
static int |
ACTION_SET_SELECTION
Action to set the selection.
|
static int |
ACTION_SET_TEXT
Action that sets the text of the node.
|
static int |
ACTIVE_WINDOW_ID |
static int |
ANY_WINDOW_ID |
static Parcelable.Creator<AccessibilityNodeInfo> |
CREATOR |
static int |
FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
static int |
FLAG_PREFETCH_DESCENDANTS |
static int |
FLAG_PREFETCH_PREDECESSORS |
static int |
FLAG_PREFETCH_SIBLINGS |
static int |
FLAG_REPORT_VIEW_IDS |
static int |
FOCUS_ACCESSIBILITY
The accessibility focus.
|
static int |
FOCUS_INPUT
The input focus.
|
static int |
MOVEMENT_GRANULARITY_CHARACTER
Movement granularity bit for traversing the text of a node by character.
|
static int |
MOVEMENT_GRANULARITY_LINE
Movement granularity bit for traversing the text of a node by line.
|
static int |
MOVEMENT_GRANULARITY_PAGE
Movement granularity bit for traversing the text of a node by page.
|
static int |
MOVEMENT_GRANULARITY_PARAGRAPH
Movement granularity bit for traversing the text of a node by paragraph.
|
static int |
MOVEMENT_GRANULARITY_WORD
Movement granularity bit for traversing the text of a node by word.
|
static long |
ROOT_NODE_ID |
static int |
UNDEFINED_CONNECTION_ID |
static int |
UNDEFINED_ITEM_ID |
static int |
UNDEFINED_SELECTION_INDEX |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
void |
addAction(AccessibilityNodeInfo.AccessibilityAction action)
Adds an action that can be performed on the node.
|
void |
addAction(int action)
Deprecated.
This has been deprecated for
addAction(AccessibilityAction) |
void |
addChild(View child)
Adds a child.
|
void |
addChild(View root,
int virtualDescendantId)
Adds a virtual child which is a descendant of the given
root . |
void |
addChildUnchecked(View child)
Unchecked version of
addChild(View) that does not verify
uniqueness. |
boolean |
canOpenPopup()
Gets if this node opens a popup or a dialog.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
protected void |
enforceNotSealed()
Enforces that this instance is not sealed.
|
protected void |
enforceSealed()
Enforces that this instance is sealed.
|
boolean |
equals(Object object)
Indicates whether some other object is "equal to" this one.
|
List<AccessibilityNodeInfo> |
findAccessibilityNodeInfosByText(String text)
Finds
AccessibilityNodeInfo s by text. |
List<AccessibilityNodeInfo> |
findAccessibilityNodeInfosByViewId(String viewId)
Finds
AccessibilityNodeInfo s by the fully qualified view id's resource
name where a fully qualified id is of the from "package:id/id_resource_name". |
AccessibilityNodeInfo |
findFocus(int focus)
Find the view that has the specified focus type.
|
AccessibilityNodeInfo |
focusSearch(int direction)
Searches for the nearest view in the specified direction that can take
the input focus.
|
static int |
getAccessibilityViewId(long accessibilityNodeId)
Gets the accessibility view id which identifies a View in the view three.
|
List<AccessibilityNodeInfo.AccessibilityAction> |
getActionList()
Gets the actions that can be performed on the node.
|
int |
getActions()
Deprecated.
Use
getActionList() . |
void |
getBoundsInParent(Rect outBounds)
Gets the node bounds in parent coordinates.
|
Rect |
getBoundsInScreen()
Returns the actual rect containing the node bounds in screen coordinates.
|
void |
getBoundsInScreen(Rect outBounds)
Gets the node bounds in screen coordinates.
|
AccessibilityNodeInfo |
getChild(int index)
Get the child at given index.
|
int |
getChildCount()
Gets the number of children.
|
long |
getChildId(int index)
Returns the id of the child at the specified index.
|
LongArray |
getChildNodeIds()
Returns the array containing the IDs of this node's children.
|
CharSequence |
getClassName()
Gets the class this node comes from.
|
AccessibilityNodeInfo.CollectionInfo |
getCollectionInfo()
Gets the collection info if the node is a collection.
|
AccessibilityNodeInfo.CollectionItemInfo |
getCollectionItemInfo()
Gets the collection item info if the node is a collection item.
|
CharSequence |
getContentDescription()
Gets the content description of this node.
|
int |
getDrawingOrder()
Get the drawing order of the view corresponding it this node.
|
CharSequence |
getError()
Gets the error text of this node.
|
Bundle |
getExtras()
Gets an optional bundle with extra data.
|
int |
getInputType()
Gets the input type of the source as defined by
InputType . |
AccessibilityNodeInfo |
getLabeledBy()
Gets the node info which serves as the label of the view represented by
this info for accessibility purposes.
|
AccessibilityNodeInfo |
getLabelFor()
Gets the node info for which the view represented by this info serves as
a label for accessibility purposes.
|
int |
getLiveRegion()
Gets the node's live region mode.
|
int |
getMaxTextLength()
Returns the maximum text length for this node.
|
int |
getMovementGranularities()
Gets the movement granularities for traversing the text of this node.
|
CharSequence |
getPackageName()
Gets the package this node comes from.
|
AccessibilityNodeInfo |
getParent()
Gets the parent.
|
long |
getParentNodeId() |
AccessibilityNodeInfo.RangeInfo |
getRangeInfo()
Gets the range info if this node is a range.
|
long |
getSourceNodeId()
Gets the id of the source node.
|
CharSequence |
getText()
Gets the text of this node.
|
int |
getTextSelectionEnd()
Gets the text selection end if text is selected.
|
int |
getTextSelectionStart()
Gets the text selection start or the cursor position.
|
AccessibilityNodeInfo |
getTraversalAfter()
Gets the node after which this one is visited in accessibility traversal.
|
AccessibilityNodeInfo |
getTraversalBefore()
Gets the node before which this one is visited during traversal.
|
String |
getViewIdResourceName()
Gets the fully qualified resource name of the source view's id.
|
static int |
getVirtualDescendantId(long accessibilityNodeId)
Gets the virtual descendant id which identifies an imaginary view in a
containing View.
|
AccessibilityWindowInfo |
getWindow()
Gets the window to which this node belongs.
|
int |
getWindowId()
Gets the id of the window from which the info comes from.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isAccessibilityFocused()
Gets whether this node is accessibility focused.
|
boolean |
isCheckable()
Gets whether this node is checkable.
|
boolean |
isChecked()
Gets whether this node is checked.
|
boolean |
isClickable()
Gets whether this node is clickable.
|
boolean |
isContentInvalid()
Gets if the content of this node is invalid.
|
boolean |
isContextClickable()
Gets whether this node is context clickable.
|
boolean |
isDismissable()
Gets if the node can be dismissed.
|
boolean |
isEditable()
Gets if the node is editable.
|
boolean |
isEnabled()
Gets whether this node is enabled.
|
boolean |
isFocusable()
Gets whether this node is focusable.
|
boolean |
isFocused()
Gets whether this node is focused.
|
boolean |
isImportantForAccessibility()
Returns whether the node originates from a view considered important for accessibility.
|
boolean |
isLongClickable()
Gets whether this node is long clickable.
|
boolean |
isMultiLine()
Gets if the node is a multi line editable text.
|
boolean |
isPassword()
Gets whether this node is a password.
|
boolean |
isScrollable()
Gets if the node is scrollable.
|
boolean |
isSealed()
Gets if this instance is sealed.
|
boolean |
isSelected()
Gets whether this node is selected.
|
boolean |
isVisibleToUser()
Gets whether this node is visible to the user.
|
static long |
makeNodeId(int accessibilityViewId,
int virtualDescendantId)
Makes a node id by shifting the
virtualDescendantId
by VIRTUAL_DESCENDANT_ID_SHIFT and taking
the bitwise or with the accessibilityViewId . |
static AccessibilityNodeInfo |
obtain()
Returns a cached instance if such is available otherwise a new one.
|
static AccessibilityNodeInfo |
obtain(AccessibilityNodeInfo info)
Returns a cached instance if such is available or a new one is
create.
|
static AccessibilityNodeInfo |
obtain(View source)
Returns a cached instance if such is available otherwise a new one
and sets the source.
|
static AccessibilityNodeInfo |
obtain(View root,
int virtualDescendantId)
Returns a cached instance if such is available otherwise a new one
and sets the source.
|
boolean |
performAction(int action)
Performs an action on the node.
|
boolean |
performAction(int action,
Bundle arguments)
Performs an action on the node.
|
void |
recycle()
Return an instance back to be reused.
|
boolean |
refresh()
Refreshes this info with the latest state of the view it represents.
|
boolean |
refresh(boolean bypassCache)
Refreshes this info with the latest state of the view it represents.
|
boolean |
removeAction(AccessibilityNodeInfo.AccessibilityAction action)
Removes an action that can be performed on the node.
|
void |
removeAction(int action)
Deprecated.
|
boolean |
removeChild(View child)
Removes a child.
|
boolean |
removeChild(View root,
int virtualDescendantId)
Removes a virtual child which is a descendant of the given
root . |
void |
setAccessibilityFocused(boolean focused)
Sets whether this node is accessibility focused.
|
void |
setBoundsInParent(Rect bounds)
Sets the node bounds in parent coordinates.
|
void |
setBoundsInScreen(Rect bounds)
Sets the node bounds in screen coordinates.
|
void |
setCanOpenPopup(boolean opensPopup)
Sets if this node opens a popup or a dialog.
|
void |
setCheckable(boolean checkable)
Sets whether this node is checkable.
|
void |
setChecked(boolean checked)
Sets whether this node is checked.
|
void |
setClassName(CharSequence className)
Sets the class this node comes from.
|
void |
setClickable(boolean clickable)
Sets whether this node is clickable.
|
void |
setCollectionInfo(AccessibilityNodeInfo.CollectionInfo collectionInfo)
Sets the collection info if the node is a collection.
|
void |
setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo collectionItemInfo)
Sets the collection item info if the node is a collection item.
|
void |
setConnectionId(int connectionId)
Sets the unique id of the IAccessibilityServiceConnection over which
this instance can send requests to the system.
|
void |
setContentDescription(CharSequence contentDescription)
Sets the content description of this node.
|
void |
setContentInvalid(boolean contentInvalid)
Sets if the content of this node is invalid.
|
void |
setContextClickable(boolean contextClickable)
Sets whether this node is context clickable.
|
void |
setDismissable(boolean dismissable)
Sets if the node can be dismissed.
|
void |
setDrawingOrder(int drawingOrderInParent)
Set the drawing order of the view corresponding it this node.
|
void |
setEditable(boolean editable)
Sets whether this node is editable.
|
void |
setEnabled(boolean enabled)
Sets whether this node is enabled.
|
void |
setError(CharSequence error)
Sets the error text of this node.
|
void |
setFocusable(boolean focusable)
Sets whether this node is focusable.
|
void |
setFocused(boolean focused)
Sets whether this node is focused.
|
void |
setImportantForAccessibility(boolean important)
Sets whether the node is considered important for accessibility.
|
void |
setInputType(int inputType)
Sets the input type of the source as defined by
InputType . |
void |
setLabeledBy(View label)
Sets the view which serves as the label of the view represented by
this info for accessibility purposes.
|
void |
setLabeledBy(View root,
int virtualDescendantId)
Sets the view which serves as the label of the view represented by
this info for accessibility purposes.
|
void |
setLabelFor(View labeled)
Sets the view for which the view represented by this info serves as a
label for accessibility purposes.
|
void |
setLabelFor(View root,
int virtualDescendantId)
Sets the view for which the view represented by this info serves as a
label for accessibility purposes.
|
void |
setLiveRegion(int mode)
Sets the node's live region mode.
|
void |
setLongClickable(boolean longClickable)
Sets whether this node is long clickable.
|
void |
setMaxTextLength(int max)
Sets the maximum text length, or -1 for no limit.
|
void |
setMovementGranularities(int granularities)
Sets the movement granularities for traversing the text of this node.
|
void |
setMultiLine(boolean multiLine)
Sets if the node is a multi line editable text.
|
void |
setPackageName(CharSequence packageName)
Sets the package this node comes from.
|
void |
setParent(View parent)
Sets the parent.
|
void |
setParent(View root,
int virtualDescendantId)
Sets the parent to be a virtual descendant of the given
root . |
void |
setPassword(boolean password)
Sets whether this node is a password.
|
void |
setRangeInfo(AccessibilityNodeInfo.RangeInfo rangeInfo)
Sets the range info if this node is a range.
|
void |
setScrollable(boolean scrollable)
Sets if the node is scrollable.
|
void |
setSealed(boolean sealed)
Sets if this instance is sealed.
|
void |
setSelected(boolean selected)
Sets whether this node is selected.
|
void |
setSource(View source)
Sets the source.
|
void |
setSource(View root,
int virtualDescendantId)
Sets the source to be a virtual descendant of the given
root . |
void |
setText(CharSequence text)
Sets the text of this node.
|
void |
setTextSelection(int start,
int end)
Sets the text selection start and end.
|
void |
setTraversalAfter(View view)
Sets the view whose node is visited after this one in accessibility traversal.
|
void |
setTraversalAfter(View root,
int virtualDescendantId)
Sets the node after which this one is visited in accessibility traversal.
|
void |
setTraversalBefore(View view)
Sets the view before whose node this one should be visited during traversal.
|
void |
setTraversalBefore(View root,
int virtualDescendantId)
Sets the node before which this one is visited during traversal.
|
void |
setViewIdResourceName(String viewIdResName)
Sets the fully qualified resource name of the source view's id.
|
void |
setVisibleToUser(boolean visibleToUser)
Sets whether this node is visible to the user.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel.
|
public static final int UNDEFINED_CONNECTION_ID
public static final int UNDEFINED_SELECTION_INDEX
public static final int UNDEFINED_ITEM_ID
public static final long ROOT_NODE_ID
public static final int ACTIVE_WINDOW_ID
public static final int ANY_WINDOW_ID
public static final int FLAG_PREFETCH_PREDECESSORS
public static final int FLAG_PREFETCH_SIBLINGS
public static final int FLAG_PREFETCH_DESCENDANTS
public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
public static final int FLAG_REPORT_VIEW_IDS
public static final int ACTION_FOCUS
public static final int ACTION_CLEAR_FOCUS
public static final int ACTION_SELECT
public static final int ACTION_CLEAR_SELECTION
public static final int ACTION_CLICK
AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK
public static final int ACTION_LONG_CLICK
public static final int ACTION_ACCESSIBILITY_FOCUS
public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS
public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY
Arguments:
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
false);
info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
<,
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the previous character and do not extend selection.
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
,
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
,
setMovementGranularities(int)
,
getMovementGranularities()
,
MOVEMENT_GRANULARITY_CHARACTER
,
MOVEMENT_GRANULARITY_WORD
,
MOVEMENT_GRANULARITY_LINE
,
MOVEMENT_GRANULARITY_PARAGRAPH
,
MOVEMENT_GRANULARITY_PAGE
,
Constant Field Valuespublic static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
Arguments:
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
false);
info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
arguments);
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
<,
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the next character and do not extend selection.
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
,
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
,
setMovementGranularities(int)
,
getMovementGranularities()
,
MOVEMENT_GRANULARITY_CHARACTER
,
MOVEMENT_GRANULARITY_WORD
,
MOVEMENT_GRANULARITY_LINE
,
MOVEMENT_GRANULARITY_PARAGRAPH
,
MOVEMENT_GRANULARITY_PAGE
,
Constant Field Valuespublic static final int ACTION_NEXT_HTML_ELEMENT
Arguments:
Bundle arguments = new Bundle();
arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
info.performAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT, arguments);
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
public static final int ACTION_PREVIOUS_HTML_ELEMENT
Arguments:
Bundle arguments = new Bundle();
arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON");
info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT, arguments);
ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
public static final int ACTION_SCROLL_FORWARD
public static final int ACTION_SCROLL_BACKWARD
public static final int ACTION_COPY
public static final int ACTION_PASTE
public static final int ACTION_CUT
public static final int ACTION_SET_SELECTION
Arguments:
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments);
ACTION_ARGUMENT_SELECTION_START_INT
,
ACTION_ARGUMENT_SELECTION_END_INT
Example:
public static final int ACTION_EXPAND
public static final int ACTION_COLLAPSE
public static final int ACTION_DISMISS
public static final int ACTION_SET_TEXT
null
or empty CharSequence
will clear the text. This action will also put the
cursor at the end of text.
Arguments:
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
"android");
info.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
Example:
public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
Type: int
Actions:
public static final String ACTION_ARGUMENT_HTML_ELEMENT_STRING
Type: String
Actions:
public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Type: boolean
Actions:
public static final String ACTION_ARGUMENT_SELECTION_START_INT
Type: int
Actions:
public static final String ACTION_ARGUMENT_SELECTION_END_INT
Type: int
Actions:
public static final String ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
Type: CharSequence
Actions:
public static final String ACTION_ARGUMENT_ROW_INT
Type: int
Actions:
public static final String ACTION_ARGUMENT_COLUMN_INT
Type: int
Actions:
public static final String ACTION_ARGUMENT_PROGRESS_VALUE
Type: float
Actions:
public static final int FOCUS_INPUT
public static final int FOCUS_ACCESSIBILITY
public static final int MOVEMENT_GRANULARITY_CHARACTER
public static final int MOVEMENT_GRANULARITY_WORD
public static final int MOVEMENT_GRANULARITY_LINE
public static final int MOVEMENT_GRANULARITY_PARAGRAPH
public static final int MOVEMENT_GRANULARITY_PAGE
public static final Parcelable.Creator<AccessibilityNodeInfo> CREATOR
Parcelable.Creator
public static int getAccessibilityViewId(long accessibilityNodeId)
accessibilityNodeId
- The id of an AccessibilityNodeInfo
.public static int getVirtualDescendantId(long accessibilityNodeId)
accessibilityNodeId
- The id of an AccessibilityNodeInfo
.public static long makeNodeId(int accessibilityViewId, int virtualDescendantId)
virtualDescendantId
by VIRTUAL_DESCENDANT_ID_SHIFT
and taking
the bitwise or with the accessibilityViewId
.accessibilityViewId
- A View accessibility id.virtualDescendantId
- A virtual descendant id.public void setSource(View source)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
source
- The info source.public void setSource(View root, int virtualDescendantId)
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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo findFocus(int focus)
focus
- The focus to find. One of FOCUS_INPUT
or
FOCUS_ACCESSIBILITY
.FOCUS_INPUT
,
FOCUS_ACCESSIBILITY
public AccessibilityNodeInfo focusSearch(int direction)
direction
- The direction. Can be one of:
View.FOCUS_DOWN
,
View.FOCUS_UP
,
View.FOCUS_LEFT
,
View.FOCUS_RIGHT
,
View.FOCUS_FORWARD
,
View.FOCUS_BACKWARD
.public int getWindowId()
public boolean refresh(boolean bypassCache)
Note: If this method returns false this info is obsolete since it represents a view that is no longer in the view tree and should be recycled.
bypassCache
- Whether to bypass the cache.public boolean refresh()
Note: If this method returns false this info is obsolete since it represents a view that is no longer in the view tree and should be recycled.
public LongArray getChildNodeIds()
public long getChildId(int index)
IndexOutOfBoundsException
- when index < 0 || index >=
getChildCount()public int getChildCount()
public AccessibilityNodeInfo getChild(int index)
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
index
- The child index.IllegalStateException
- If called outside of an AccessibilityService.public void addChild(View child)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
child
- The child.IllegalStateException
- If called from an AccessibilityService.public void addChildUnchecked(View child)
addChild(View)
that does not verify
uniqueness. For framework use only.public boolean removeChild(View child)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
child
- The child.IllegalStateException
- If called from an AccessibilityService.public void addChild(View root, int virtualDescendantId)
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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual child.public boolean removeChild(View root, int virtualDescendantId)
root
. If the child was not previously added to the node,
calling this method has no effect.root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual child.addChild(View, int)
public List<AccessibilityNodeInfo.AccessibilityAction> getActionList()
@Deprecated public int getActions()
getActionList()
.ACTION_FOCUS
,
ACTION_CLEAR_FOCUS
,
ACTION_SELECT
,
ACTION_CLEAR_SELECTION
,
ACTION_ACCESSIBILITY_FOCUS
,
ACTION_CLEAR_ACCESSIBILITY_FOCUS
,
ACTION_CLICK
,
ACTION_LONG_CLICK
,
ACTION_NEXT_AT_MOVEMENT_GRANULARITY
,
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
,
ACTION_NEXT_HTML_ELEMENT
,
ACTION_PREVIOUS_HTML_ELEMENT
,
ACTION_SCROLL_FORWARD
,
ACTION_SCROLL_BACKWARD
public void addAction(AccessibilityNodeInfo.AccessibilityAction action)
To add a standard action use the static constants on AccessibilityNodeInfo.AccessibilityAction
.
To add a custom action create a new AccessibilityNodeInfo.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.
action
- The action.IllegalStateException
- If called from an AccessibilityService.@Deprecated public void addAction(int action)
addAction(AccessibilityAction)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
action
- The action.IllegalStateException
- If called from an AccessibilityService.IllegalArgumentException
- If the argument is not one of the standard actions.@Deprecated public void removeAction(int action)
removeAction(AccessibilityAction)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
action
- The action to be removed.IllegalStateException
- If called from an AccessibilityService.public boolean removeAction(AccessibilityNodeInfo.AccessibilityAction action)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
action
- The action to be removed.IllegalStateException
- If called from an AccessibilityService.public AccessibilityNodeInfo getTraversalBefore()
null
.setTraversalBefore(android.view.View)
,
setTraversalBefore(android.view.View, int)
public void setTraversalBefore(View view)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
view
- The view providing the preceding node.getTraversalBefore()
public void setTraversalBefore(View root, int virtualDescendantId)
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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo getTraversalAfter()
null
.setTraversalAfter(android.view.View)
,
setTraversalAfter(android.view.View, int)
public void setTraversalAfter(View view)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
view
- The previous view.getTraversalAfter()
public void setTraversalAfter(View root, int virtualDescendantId)
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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public void setMaxTextLength(int max)
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.
max
- The maximum text length.IllegalStateException
- If called from an AccessibilityService.getMaxTextLength()
public int getMaxTextLength()
setMaxTextLength(int)
public void setMovementGranularities(int granularities)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
granularities
- The bit mask with granularities.IllegalStateException
- If called from an AccessibilityService.public int getMovementGranularities()
public boolean performAction(int action)
Note: An action can be performed only if the request is made
from an AccessibilityService
.
action
- The action to perform.IllegalStateException
- If called outside of an AccessibilityService.public boolean performAction(int action, Bundle arguments)
Note: An action can be performed only if the request is made
from an AccessibilityService
.
action
- The action to perform.arguments
- A bundle with additional arguments.IllegalStateException
- If called outside of an AccessibilityService.public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text)
AccessibilityNodeInfo
s by text. The match is case
insensitive containment. The search is relative to this info i.e.
this info is the root of the traversed tree.
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
text
- The searched text.public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId(String viewId)
AccessibilityNodeInfo
s 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 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 his AccessibilityService
.
viewId
- The fully qualified resource name of the view id to find.public AccessibilityWindowInfo getWindow()
AccessibilityService.getWindows()
public AccessibilityNodeInfo getParent()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public long getParentNodeId()
public void setParent(View parent)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
parent
- The parent.IllegalStateException
- If called from an AccessibilityService.public void setParent(View root, int virtualDescendantId)
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.
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.public void getBoundsInParent(Rect outBounds)
outBounds
- The output node bounds.public void setBoundsInParent(Rect bounds)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
bounds
- The node bounds.IllegalStateException
- If called from an AccessibilityService.public void getBoundsInScreen(Rect outBounds)
outBounds
- The output node bounds.public Rect getBoundsInScreen()
public void setBoundsInScreen(Rect bounds)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
bounds
- The node bounds.IllegalStateException
- If called from an AccessibilityService.public boolean isCheckable()
public void setCheckable(boolean checkable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
checkable
- True if the node is checkable.IllegalStateException
- If called from an AccessibilityService.public boolean isChecked()
public void setChecked(boolean checked)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
checked
- True if the node is checked.IllegalStateException
- If called from an AccessibilityService.public boolean isFocusable()
public void setFocusable(boolean focusable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focusable
- True if the node is focusable.IllegalStateException
- If called from an AccessibilityService.public boolean isFocused()
public void setFocused(boolean focused)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focused
- True if the node is focused.IllegalStateException
- If called from an AccessibilityService.public boolean isVisibleToUser()
public void setVisibleToUser(boolean visibleToUser)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
visibleToUser
- Whether the node is visible to the user.IllegalStateException
- If called from an AccessibilityService.public boolean isAccessibilityFocused()
public void setAccessibilityFocused(boolean focused)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
focused
- True if the node is accessibility focused.IllegalStateException
- If called from an AccessibilityService.public boolean isSelected()
public void setSelected(boolean selected)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
selected
- True if the node is selected.IllegalStateException
- If called from an AccessibilityService.public boolean isClickable()
public void setClickable(boolean clickable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
clickable
- True if the node is clickable.IllegalStateException
- If called from an AccessibilityService.public boolean isLongClickable()
public void setLongClickable(boolean longClickable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
longClickable
- True if the node is long clickable.IllegalStateException
- If called from an AccessibilityService.public boolean isEnabled()
public void setEnabled(boolean enabled)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
enabled
- True if the node is enabled.IllegalStateException
- If called from an AccessibilityService.public boolean isPassword()
public void setPassword(boolean password)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
password
- True if the node is a password.IllegalStateException
- If called from an AccessibilityService.public boolean isScrollable()
public void setScrollable(boolean scrollable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
scrollable
- True if the node is scrollable, false otherwise.IllegalStateException
- If called from an AccessibilityService.public boolean isEditable()
public void setEditable(boolean editable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
editable
- True if the node is editable.IllegalStateException
- If called from an AccessibilityService.public int getDrawingOrder()
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.
public void setDrawingOrder(int drawingOrderInParent)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
drawingOrderInParent
- IllegalStateException
- If called from an AccessibilityService.public AccessibilityNodeInfo.CollectionInfo getCollectionInfo()
public void setCollectionInfo(AccessibilityNodeInfo.CollectionInfo collectionInfo)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
collectionInfo
- The collection info.public AccessibilityNodeInfo.CollectionItemInfo getCollectionItemInfo()
public void setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo collectionItemInfo)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
public AccessibilityNodeInfo.RangeInfo getRangeInfo()
public void setRangeInfo(AccessibilityNodeInfo.RangeInfo rangeInfo)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
rangeInfo
- The range info.public boolean isContentInvalid()
public void setContentInvalid(boolean contentInvalid)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
contentInvalid
- If the node content is invalid.public boolean isContextClickable()
public void setContextClickable(boolean contextClickable)
Note: Cannot be called from an
AccessibilityService
. This class is made immutable
before being delivered to an AccessibilityService.
contextClickable
- True if the node is context clickable.IllegalStateException
- If called from an AccessibilityService.public int getLiveRegion()
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.
View.ACCESSIBILITY_LIVE_REGION_NONE
if the view is not a
live region.View.getAccessibilityLiveRegion()
public void setLiveRegion(int mode)
Note: Cannot be called from an
AccessibilityService
. This class is
made immutable before being delivered to an AccessibilityService.
mode
- The live region mode, or
View.ACCESSIBILITY_LIVE_REGION_NONE
if the view is not a
live region.View.setAccessibilityLiveRegion(int)
public boolean isMultiLine()
public void setMultiLine(boolean multiLine)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
multiLine
- True if the node is multi line.public boolean canOpenPopup()
public void setCanOpenPopup(boolean opensPopup)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
opensPopup
- If the the node opens a popup.public boolean isDismissable()
public void setDismissable(boolean dismissable)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
dismissable
- If the node can be dismissed.public boolean isImportantForAccessibility()
true
if the node originates from a view considered important for
accessibility, false
otherwiseView.isImportantForAccessibility()
public void setImportantForAccessibility(boolean important)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
important
- true
if the node is considered important for accessibility,
false
otherwisepublic CharSequence getPackageName()
public void setPackageName(CharSequence packageName)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
packageName
- The package name.IllegalStateException
- If called from an AccessibilityService.public CharSequence getClassName()
public void setClassName(CharSequence className)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
className
- The class name.IllegalStateException
- If called from an AccessibilityService.public CharSequence getText()
public void setText(CharSequence text)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
text
- The text.IllegalStateException
- If called from an AccessibilityService.public void setError(CharSequence error)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
error
- The error text.IllegalStateException
- If called from an AccessibilityService.public CharSequence getError()
public CharSequence getContentDescription()
public void setContentDescription(CharSequence contentDescription)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
contentDescription
- The content description.IllegalStateException
- If called from an AccessibilityService.public void setLabelFor(View labeled)
labeled
- The view for which this info serves as a label.public void setLabelFor(View root, int virtualDescendantId)
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.
root
- The root whose virtual descendant serves as a label.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo getLabelFor()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public void setLabeledBy(View label)
label
- The view that labels this node's source.public void setLabeledBy(View root, int virtualDescendantId)
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.
root
- The root whose virtual descendant labels this node's source.virtualDescendantId
- The id of the virtual descendant.public AccessibilityNodeInfo getLabeledBy()
Note: It is a client responsibility to recycle the
received info by calling recycle()
to avoid creating of multiple instances.
public void setViewIdResourceName(String viewIdResName)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
viewIdResName
- The id resource name.public String getViewIdResourceName()
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 his AccessibilityService
.
public int getTextSelectionStart()
If no text is selected, both this method and
getTextSelectionEnd()
return the same value:
the current location of the cursor.
public int getTextSelectionEnd()
If no text is selected, both this method and
getTextSelectionStart()
return the same value:
the current location of the cursor.
public void setTextSelection(int start, int end)
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an AccessibilityService.
start
- The text selection start.end
- The text selection end.IllegalStateException
- If called from an AccessibilityService.public int getInputType()
InputType
.public void setInputType(int inputType)
InputType
.
Note: Cannot be called from an
AccessibilityService
.
This class is made immutable before being delivered to an
AccessibilityService.
inputType
- The input type.IllegalStateException
- If called from an AccessibilityService.public Bundle getExtras()
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.
public void setConnectionId(int connectionId)
connectionId
- The connection id.public int describeContents()
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public long getSourceNodeId()
public void setSealed(boolean sealed)
sealed
- Whether is sealed.public boolean isSealed()
protected void enforceSealed()
IllegalStateException
- If this instance is not sealed.protected void enforceNotSealed()
IllegalStateException
- If this instance is sealed.public static AccessibilityNodeInfo obtain(View source)
source
- The source view.setSource(View)
public static AccessibilityNodeInfo obtain(View root, int virtualDescendantId)
root
- The root of the virtual subtree.virtualDescendantId
- The id of the virtual descendant.setSource(View, int)
public static AccessibilityNodeInfo obtain()
public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info)
info
.info
- The other info.public void recycle()
Note: You must not touch the object after calling this function.
IllegalStateException
- If the info is already recycled.public void writeToParcel(Parcel parcel, int flags)
Note: After the instance is written to a parcel it is recycled. You must not touch the object after calling this function.
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public boolean equals(Object object)
Object
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
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.
x
,
x.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.
equals
in class Object
object
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
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.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.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
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
Object
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())