IT. Expert System.

Android Reference

AccessibilityNodeInfo


android.view.accessibility

Class AccessibilityNodeInfo

  • All Implemented Interfaces:
    Parcelable


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

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

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

    Developer Guides

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

    See Also:
    AccessibilityService, AccessibilityEvent, AccessibilityManager
    • Method Detail

      • getAccessibilityViewId

        public static int getAccessibilityViewId(long accessibilityNodeId)
        Gets the accessibility view id which identifies a View in the view three.
        Parameters:
        accessibilityNodeId - The id of an AccessibilityNodeInfo.
        Returns:
        The accessibility view id part of the node id.
      • getVirtualDescendantId

        public static int getVirtualDescendantId(long accessibilityNodeId)
        Gets the virtual descendant id which identifies an imaginary view in a containing View.
        Parameters:
        accessibilityNodeId - The id of an AccessibilityNodeInfo.
        Returns:
        The virtual view id part of the node id.
      • makeNodeId

        public 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.
        Parameters:
        accessibilityViewId - A View accessibility id.
        virtualDescendantId - A virtual descendant id.
        Returns:
        The node id.
      • setSource

        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:
        source - The info source.
      • setSource

        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:
        root - The root of the virtual subtree.
        virtualDescendantId - The id of the virtual descendant.
      • getWindowId

        public int getWindowId()
        Gets the id of the window from which the info comes from.
        Returns:
        The window id.
      • getChildNodeIds

        public SparseLongArray getChildNodeIds()
        Returns:
        The ids of the children.
      • getChildCount

        public int getChildCount()
        Gets the number of children.
        Returns:
        The child count.
      • getChild

        public AccessibilityNodeInfo getChild(int index)
        Get the child at given index.

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

        Parameters:
        index - The child index.
        Returns:
        The child node.
        Throws:
        IllegalStateException - If called outside of an AccessibilityService.
      • addChild

        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.

        Parameters:
        child - The child.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • addChild

        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.

        Parameters:
        root - The root of the virtual subtree.
        virtualDescendantId - The id of the virtual child.
      • addAction

        public void addAction(int action)
        Adds an action that can be performed on the node.

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

        Parameters:
        action - The action.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • setMovementGranularities

        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:
        granularities - The bit mask with granularities.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getMovementGranularities

        public int getMovementGranularities()
        Gets the movement granularities for traversing the text of this node.
        Returns:
        The bit mask with granularities.
      • performAction

        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:
        action - The action to perform.
        Returns:
        True if the action was performed.
        Throws:
        IllegalStateException - If called outside of an AccessibilityService.
      • performAction

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

        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 recycle() to avoid creating of multiple instances.

        Parameters:
        text - The searched text.
        Returns:
        A list of node info.
      • getParent

        public AccessibilityNodeInfo getParent()
        Gets the parent.

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

        Returns:
        The parent.
      • getParentNodeId

        public long getParentNodeId()
        Returns:
        The parent node id.
      • setParent

        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:
        parent - The parent.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • setParent

        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:
        root - The root of the virtual subtree.
        virtualDescendantId - The id of the virtual descendant.
      • getBoundsInParent

        public void getBoundsInParent(Rect outBounds)
        Gets the node bounds in parent coordinates.
        Parameters:
        outBounds - The output node bounds.
      • setBoundsInParent

        public void setBoundsInParent(Rect bounds)
        Sets the node bounds in parent coordinates.

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

        Parameters:
        bounds - The node bounds.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getBoundsInScreen

        public void getBoundsInScreen(Rect outBounds)
        Gets the node bounds in screen coordinates.
        Parameters:
        outBounds - The output node bounds.
      • setBoundsInScreen

        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:
        bounds - The node bounds.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isCheckable

        public boolean isCheckable()
        Gets whether this node is checkable.
        Returns:
        True if the node is checkable.
      • setCheckable

        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:
        checkable - True if the node is checkable.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isChecked

        public boolean isChecked()
        Gets whether this node is checked.
        Returns:
        True if the node is checked.
      • setChecked

        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:
        checked - True if the node is checked.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isFocusable

        public boolean isFocusable()
        Gets whether this node is focusable.
        Returns:
        True if the node is focusable.
      • setFocusable

        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:
        focusable - True if the node is focusable.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isFocused

        public boolean isFocused()
        Gets whether this node is focused.
        Returns:
        True if the node is focused.
      • setFocused

        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:
        focused - True if the node is focused.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isVisibleToUser

        public boolean isVisibleToUser()
        Sets whether this node is visible to the user.
        Returns:
        Whether the node is visible to the user.
      • setVisibleToUser

        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:
        visibleToUser - Whether the node is visible to the user.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isAccessibilityFocused

        public boolean isAccessibilityFocused()
        Gets whether this node is accessibility focused.
        Returns:
        True if the node is accessibility focused.
      • setAccessibilityFocused

        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:
        focused - True if the node is accessibility focused.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isSelected

        public boolean isSelected()
        Gets whether this node is selected.
        Returns:
        True if the node is selected.
      • setSelected

        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:
        selected - True if the node is selected.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isClickable

        public boolean isClickable()
        Gets whether this node is clickable.
        Returns:
        True if the node is clickable.
      • setClickable

        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:
        clickable - True if the node is clickable.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isLongClickable

        public boolean isLongClickable()
        Gets whether this node is long clickable.
        Returns:
        True if the node is long clickable.
      • setLongClickable

        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:
        longClickable - True if the node is long clickable.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isEnabled

        public boolean isEnabled()
        Gets whether this node is enabled.
        Returns:
        True if the node is enabled.
      • setEnabled

        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:
        enabled - True if the node is enabled.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isPassword

        public boolean isPassword()
        Gets whether this node is a password.
        Returns:
        True if the node is a password.
      • setPassword

        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:
        password - True if the node is a password.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • isScrollable

        public boolean isScrollable()
        Gets if the node is scrollable.
        Returns:
        True if the node is scrollable, false otherwise.
      • setScrollable

        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:
        scrollable - True if the node is scrollable, false otherwise.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getPackageName

        public CharSequence getPackageName()
        Gets the package this node comes from.
        Returns:
        The package name.
      • setPackageName

        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:
        packageName - The package name.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getClassName

        public CharSequence getClassName()
        Gets the class this node comes from.
        Returns:
        The class name.
      • setClassName

        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:
        className - The class name.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getText

        public CharSequence getText()
        Gets the text of this node.
        Returns:
        The text.
      • setText

        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:
        text - The text.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • getContentDescription

        public CharSequence getContentDescription()
        Gets the content description of this node.
        Returns:
        The content description.
      • setContentDescription

        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:
        contentDescription - The content description.
        Throws:
        IllegalStateException - If called from an AccessibilityService.
      • setLabelFor

        public void setLabelFor(View labeled)
        Sets the view for which the view represented by this info serves as a label for accessibility purposes.
        Parameters:
        labeled - The view for which this info serves as a label.
      • setLabelFor

        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:
        root - The root whose virtual descendant serves as a label.
        virtualDescendantId - The id of the virtual descendant.
      • getLabelFor

        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 recycle() to avoid creating of multiple instances.

        Returns:
        The labeled info.
      • setLabeledBy

        public void setLabeledBy(View label)
        Sets the view which serves as the label of the view represented by this info for accessibility purposes.
        Parameters:
        label - The view that labels this node's source.
      • setLabeledBy

        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:
        root - The root whose virtual descendant labels this node's source.
        virtualDescendantId - The id of the virtual descendant.
      • getLabeledBy

        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 recycle() to avoid creating of multiple instances.

        Returns:
        The label.
      • setConnectionId

        public void setConnectionId(int connectionId)
        Sets the unique id of the IAccessibilityServiceConnection over which this instance can send requests to the system.
        Parameters:
        connectionId - The connection id.
      • describeContents

        public int describeContents()
        Describe the kinds of special objects contained in this Parcelable's marshalled representation.
        Specified by:
        describeContents in interface Parcelable
        Returns:
        a bitmask indicating the set of special object types marshalled by the Parcelable.
      • getSourceNodeId

        public long getSourceNodeId()
        Gets the id of the source node.
        Returns:
        The id.
      • setSealed

        public void setSealed(boolean sealed)
        Sets if this instance is sealed.
        Parameters:
        sealed - Whether is sealed.
      • isSealed

        public boolean isSealed()
        Gets if this instance is sealed.
        Returns:
        Whether is sealed.
      • enforceSealed

        protected void enforceSealed()
        Enforces that this instance is sealed.
        Throws:
        IllegalStateException - If this instance is not sealed.
      • enforceNotSealed

        protected void enforceNotSealed()
        Enforces that this instance is not sealed.
        Throws:
        IllegalStateException - If this instance is sealed.
      • obtain

        public static AccessibilityNodeInfo obtain(View source)
        Returns a cached instance if such is available otherwise a new one and sets the source.
        Parameters:
        source - The source view.
        Returns:
        An instance.
        See Also:
        setSource(View)
      • obtain

        public static AccessibilityNodeInfo obtain(View root,
                                   int virtualDescendantId)
        Returns a cached instance if such is available otherwise a new one and sets the source.
        Parameters:
        root - The root of the virtual subtree.
        virtualDescendantId - The id of the virtual descendant.
        Returns:
        An instance.
        See Also:
        setSource(View, int)
      • obtain

        public static AccessibilityNodeInfo obtain()
        Returns a cached instance if such is available otherwise a new one.
        Returns:
        An instance.
      • obtain

        public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info)
        Returns a cached instance if such is available or a new one is create. The returned instance is initialized from the given info.
        Parameters:
        info - The other info.
        Returns:
        An instance.
      • recycle

        public void recycle()
        Return an instance back to be reused.

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

        Throws:
        IllegalStateException - If the info is already recycled.
      • writeToParcel

        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.

        Specified by:
        writeToParcel in interface Parcelable
        Parameters:
        parcel - The Parcel in which the object should be written.
        flags - Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
      • equals

        public boolean equals(Object object)
        Description copied from class: Object
        Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

        The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

        The general contract for the equals and Object.hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

        Overrides:
        equals in class Object
        Parameters:
        object - the object to compare this instance with.
        Returns:
        true if the specified object is equal to this Object; false otherwise.
        See Also:
        Object.hashCode()
      • hashCode

        public int hashCode()
        Description copied from class: Object
        Returns an integer hash code for this object. By contract, any two objects for which Object.equals(java.lang.Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

        Note that hash values must not change over time unless information used in equals comparisons also changes.

        See Writing a correct hashCode method if you intend implementing your own hashCode method.

        Overrides:
        hashCode in class Object
        Returns:
        this object's hash code.
        See Also:
        Object.equals(java.lang.Object)
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

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

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3084 / . Delta: 0.04568 с