Added in API level 4

AccessibilityEvent

class AccessibilityEvent : AccessibilityRecord, Parcelable
kotlin.Any
   ↳ android.view.accessibility.AccessibilityRecord
   ↳ android.view.accessibility.AccessibilityEvent

This class represents accessibility events that are sent by the system when something notable happens in the user interface. For example, when a android.widget.Button is clicked, a android.view.View is focused, etc.

An accessibility event is fired by an individual view which populates the event with data for its state and requests from its parent to send the event to interested parties. The parent can optionally modify or even block the event based on its broader understanding of the user interface's context.

The main purpose of an accessibility event is to communicate changes in the UI to an android.accessibilityservice.AccessibilityService. If needed, the service may then inspect the user interface by examining the View hierarchy through the event's source, as represented by a tree of AccessibilityNodeInfos (snapshot of a View state) which can be used for exploring the window content. Note that the privilege for accessing an event's source, thus the window content, has to be explicitly requested. For more details refer to android.accessibilityservice.AccessibilityService. If an accessibility service has not requested to retrieve the window content the event will not contain reference to its source. Note: for events of type TYPE_NOTIFICATION_STATE_CHANGED the source is never available, and Views that set android.view.View#isAccessibilityDataSensitive() may not populate all event properties on events sent from higher up in the view hierarchy.

This class represents various semantically different accessibility event types. Each event type has an associated set of related properties. In other words, each event type is characterized via a subset of the properties exposed by this class. For each event type there is a corresponding constant defined in this class. Follows a specification of the event types and their associated properties:

VIEW TYPES

View clicked - represents the event of clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc.
Type:TYPE_VIEW_CLICKED
Properties:

View long clicked - represents the event of long clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc
Type:TYPE_VIEW_LONG_CLICKED
Properties:

View selected - represents the event of selecting an item usually in the context of an android.widget.AdapterView.
Type: TYPE_VIEW_SELECTED
Properties:

View focused - represents the event of focusing a android.view.View.
Type: TYPE_VIEW_FOCUSED
Properties:

View text changed - represents the event of changing the text of an android.widget.EditText.
Type: TYPE_VIEW_TEXT_CHANGED
Properties:

View text selection changed - represents the event of changing the text selection of an android.widget.EditText.
Type: TYPE_VIEW_TEXT_SELECTION_CHANGED
Properties:

View text traversed at movement granularity - represents the event of traversing the text of a view at a given granularity. For example, moving to the next word.
Type: TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
Properties:
  • getEventType() - The type of the event.
  • getSource() - The source info (for registered clients).
  • getClassName() - The class name of the source.
  • getPackageName() - The package name of the source.
  • getEventTime() - The event time.
  • getMovementGranularity() - Sets the granularity at which a view's text was traversed.
  • getText() - The text of the source's sub-tree.
  • getFromIndex() - The start the text that was skipped over in this movement. This is the starting point when moving forward through the text, but not when moving back.
  • getToIndex() - The end of the text that was skipped over in this movement. This is the ending point when moving forward through the text, but not when moving back.
  • getAction() - Gets traversal action which specifies the direction.

View scrolled - represents the event of scrolling a view.
Type: TYPE_VIEW_SCROLLED
Properties:

TRANSITION TYPES

Window state changed - represents the event of a change to a section of the user interface that is visually distinct. Should be sent from either the root view of a window or from a view that is marked as a pane android.view.View#setAccessibilityPaneTitle(CharSequence). Note that changes to true windows are represented by TYPE_WINDOWS_CHANGED.
Type: TYPE_WINDOW_STATE_CHANGED
Properties:

Window content changed - represents the event of change in the content of a window. This change can be adding/removing view, changing a view size, etc.

Type: TYPE_WINDOW_CONTENT_CHANGED
Properties:

Windows changed - represents a change in the windows shown on the screen such as a window appeared, a window disappeared, a window size changed, a window layer changed, etc. These events should only come from the system, which is responsible for managing windows. The list of windows is available from android.accessibilityservice.AccessibilityService#getWindows(). For regions of the user interface that are presented as windows but are controlled by an app's process, use TYPE_WINDOW_STATE_CHANGED.
Type: TYPE_WINDOWS_CHANGED
Properties:

Note: You can retrieve the AccessibilityWindowInfo for the window source of the event by looking through the list returned by android.accessibilityservice.AccessibilityService#getWindows() for the window whose ID matches getWindowId().

NOTIFICATION TYPES

Notification state changed - represents the event showing a transient piece of information to the user. This information may be a android.app.Notification or android.widget.Toast.
Type: TYPE_NOTIFICATION_STATE_CHANGED
Properties:

EXPLORATION TYPES

View hover enter - represents the event of beginning to hover over a android.view.View. The hover may be generated via exploring the screen by touch or via a pointing device.
Type: TYPE_VIEW_HOVER_ENTER
Properties:

View hover exit - represents the event of stopping to hover over a android.view.View. The hover may be generated via exploring the screen by touch or via a pointing device.
Type: TYPE_VIEW_HOVER_EXIT
Properties:

View scrolled to - represents the event of a target node brought on screen by ACTION_SCROLL_IN_DIRECTION. Type: TYPE_VIEW_TARGETED_BY_SCROLL
Properties:

Touch interaction start - represents the event of starting a touch interaction, which is the user starts touching the screen.
Type: TYPE_TOUCH_INTERACTION_START
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

Touch interaction end - represents the event of ending a touch interaction, which is the user stops touching the screen.
Type: TYPE_TOUCH_INTERACTION_END
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

Touch exploration gesture start - represents the event of starting a touch exploring gesture.
Type: TYPE_TOUCH_EXPLORATION_GESTURE_START
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

Touch exploration gesture end - represents the event of ending a touch exploring gesture.
Type: TYPE_TOUCH_EXPLORATION_GESTURE_END
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

Touch gesture detection start - represents the event of starting a user gesture detection.
Type: TYPE_GESTURE_DETECTION_START
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

Touch gesture detection end - represents the event of ending a user gesture detection.
Type: TYPE_GESTURE_DETECTION_END
Properties:

Note: This event is fired only by the system and is not passed to the view tree to be populated.

MISCELLANEOUS TYPES

Announcement - represents the event of an application requesting a screen reader to make an announcement. Because the event carries no semantic meaning, this event is appropriate only in exceptional situations where additional screen reader output is needed but other types of accessibility services do not need to be aware of the change.
Type: TYPE_ANNOUNCEMENT
Properties:

speechStateChanged Type: TYPE_SPEECH_STATE_CHANGE
Represents a change in the speech state defined by the bit mask of the speech state change types. A change in the speech state occurs when an application wants to signal that it is either speaking or listening for human speech. This event helps avoid conflicts where two applications want to speak or one listens when another speaks. When sending this event, the sender should ensure that the accompanying state change types make sense. For example, the sender should not send SPEECH_STATE_SPEAKING_START and SPEECH_STATE_SPEAKING_END together. Properties:

Summary

Constants
static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The node's content description changed.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its content validity returned by AccessibilityNodeInfo#isContentInvalid.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag in with accessibility enabled has ended.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag in with accessibility enabled has ended.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag has started while accessibility is enabled.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its ability to interact returned by AccessibilityNodeInfo#isEnabled.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its erroneous content's error message returned by AccessibilityNodeInfo#getError.

static Int

Change type for TYPE_WINDOW_STATE_CHANGED event: The node has a pane title, and either just appeared or just was assigned a title when it had none before.

static Int

Change type for TYPE_WINDOW_STATE_CHANGED event: Can mean one of two slightly different things.

static Int

Change type for TYPE_WINDOW_STATE_CHANGED event: The node's pane title changed.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: state description of the node as returned by AccessibilityNodeInfo#getStateDescription changed.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: One or more content changes occurred in the the subtree rooted at the source node, or the subtree's structure changed when a node was added or removed.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The node's text changed.

static Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The type of change is not defined.

static Int

Invalid selection/focus position.

static Int

Maximum length of the text fields.

static Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is no longer listening to the microphone.

static Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is listening to the microphone.

static Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is no longer speaking.

static Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is speaking.

static Int

Mask for AccessibilityEvent all types.

static Int

Represents the event of an application making an announcement.

static Int

Represents the event of the assistant currently reading the users screen context.

static Int

Represents the event of ending gesture detection.

static Int

Represents the event of beginning gesture detection.

static Int

Represents the event showing a android.app.Notification.

static Int

Represents a change in the speech state defined by the speech state change types.

static Int

Represents the event of ending a touch exploration gesture.

static Int

Represents the event of starting a touch exploration gesture.

static Int

Represents the event of the user ending to touch the screen.

static Int

Represents the event of the user starting to touch the screen.

static Int

Represents the event of gaining accessibility focus.

static Int

Represents the event of clearing accessibility focus.

static Int

Represents the event of clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc.

static Int

Represents the event of a context click on a android.view.View.

static Int

Represents the event of setting input focus of a android.view.View.

static Int

Represents the event of a hover enter over a android.view.View.

static Int

Represents the event of a hover exit over a android.view.View.

static Int

Represents the event of long clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc.

static Int

Represents the event of scrolling a view.

static Int

Represents the event of selecting an item usually in the context of an android.widget.AdapterView.

static Int

Represents the event of a scroll having completed and brought the target node on screen.

static Int

Represents the event of changing the text of an android.widget.EditText.

static Int

Represents the event of changing the selection in an android.widget.EditText.

static Int

Represents the event of traversing the text of a view at a given movement granularity.

static Int

Represents the event change in the system windows shown on the screen.

static Int

Represents the event of changing the content of a window and more specifically the sub-tree rooted at the event's source.

static Int

Represents the event of a change to a visually distinct section of the user interface.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isAccessibilityFocused() changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isActive() changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window was added.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's bounds changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's children changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isFocused() changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's layer changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's parent changed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window either entered or exited picture-in-picture mode.

static Int

Change type for TYPE_WINDOWS_CHANGED event: A window was removed.

static Int

Change type for TYPE_WINDOWS_CHANGED event: The window's title changed.

Inherited constants
Public constructors

Creates a new AccessibilityEvent.

AccessibilityEvent(eventType: Int)

Creates a new AccessibilityEvent with the given eventType.

Copy constructor.

Public methods
Unit

Appends an AccessibilityRecord to the end of event records.

Int

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

static String!
eventTypeToString(eventType: Int)

Returns the string representation of an event type.

Int

Gets the performed action that triggered this event.

Int

Gets the bit mask of change types signaled by a TYPE_WINDOW_CONTENT_CHANGED event or TYPE_WINDOW_STATE_CHANGED.

Long

Gets the time in which this event was sent.

Int

Gets the event type.

Int

Gets the movement granularity that was traversed.

CharSequence!

Gets the package name of the source.

AccessibilityRecord!
getRecord(index: Int)

Gets the record at a given index.

Int

Gets the number of records contained in the event.

Int

Gets the bit mask of the speech state signaled by a TYPE_SPEECH_STATE_CHANGE event.

Int

Get the bit mask of change types signaled by a TYPE_WINDOWS_CHANGED event.

Unit

Creates a new instance from a Parcel.

Boolean

Whether the event should only be delivered to an android.accessibilityservice.AccessibilityService with the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.

static AccessibilityEvent!
obtain(eventType: Int)

Instantiates a new AccessibilityEvent instance with its type property set.

static AccessibilityEvent!

Instantiates a new AccessibilityEvent instance.

static AccessibilityEvent!

Instantiates a new AccessibilityEvent instance.

Unit

Previously would recycle an instance back to be reused.

Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Boolean)

Sets whether the event should only be delivered to an android.accessibilityservice.AccessibilityService with the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.

Unit
setAction(action: Int)

Sets the performed action that triggered this event.

Unit
setContentChangeTypes(changeTypes: Int)

Sets the bit mask of node tree changes signaled by an TYPE_WINDOW_CONTENT_CHANGED event.

Unit
setEventTime(eventTime: Long)

Sets the time in which this event was sent.

Unit
setEventType(eventType: Int)

Sets the event type.

Unit

Sets the movement granularity that was traversed.

Unit

Sets the package name of the source.

Unit

Sets the bit mask of the speech state change types signaled by a TYPE_SPEECH_STATE_CHANGE event.

String

Unit
writeToParcel(parcel: Parcel, flags: Int)

Flatten this object in to a Parcel.

Inherited functions
Properties
static Parcelable.Creator<AccessibilityEvent!>

Constants

CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION

Added in API level 19
static val CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The node's content description changed.

Value: 4

CONTENT_CHANGE_TYPE_CONTENT_INVALID

Added in API level 34
static val CONTENT_CHANGE_TYPE_CONTENT_INVALID: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its content validity returned by AccessibilityNodeInfo#isContentInvalid. The view changing content validity should call AccessibilityNodeInfo#setContentInvalid and then send this event.

Value: 1024

CONTENT_CHANGE_TYPE_DRAG_CANCELLED

Added in API level 32
static val CONTENT_CHANGE_TYPE_DRAG_CANCELLED: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag in with accessibility enabled has ended. This means the content has been unsuccessfully dropped, the user has canceled the action via an AccessibilityAction, or no drop has been detected within a timeout and the drag was automatically cancelled. This is sent from the source that initiated the drag.

Value: 512

CONTENT_CHANGE_TYPE_DRAG_DROPPED

Added in API level 32
static val CONTENT_CHANGE_TYPE_DRAG_DROPPED: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag in with accessibility enabled has ended. This means the content has been successfully dropped. This is sent from the target that accepted the dragged content.

Value: 256

CONTENT_CHANGE_TYPE_DRAG_STARTED

Added in API level 32
static val CONTENT_CHANGE_TYPE_DRAG_STARTED: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A drag has started while accessibility is enabled. This is either via an AccessibilityAction, or via touch events. This is sent from the source that initiated the drag.

Value: 128

CONTENT_CHANGE_TYPE_ENABLED

Added in API level 34
static val CONTENT_CHANGE_TYPE_ENABLED: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its ability to interact returned by AccessibilityNodeInfo#isEnabled. The view changing content's ability to interact should call AccessibilityNodeInfo#setEnabled and then send this event.

Value: 4096

CONTENT_CHANGE_TYPE_ERROR

Added in API level 34
static val CONTENT_CHANGE_TYPE_ERROR: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The source node changed its erroneous content's error message returned by AccessibilityNodeInfo#getError. The view changing erroneous content's error message should call AccessibilityNodeInfo#setError and then send this event.

Value: 2048

CONTENT_CHANGE_TYPE_PANE_APPEARED

Added in API level 28
static val CONTENT_CHANGE_TYPE_PANE_APPEARED: Int

Change type for TYPE_WINDOW_STATE_CHANGED event: The node has a pane title, and either just appeared or just was assigned a title when it had none before.

Value: 16

CONTENT_CHANGE_TYPE_PANE_DISAPPEARED

Added in API level 28
static val CONTENT_CHANGE_TYPE_PANE_DISAPPEARED: Int

Change type for TYPE_WINDOW_STATE_CHANGED event: Can mean one of two slightly different things. The primary meaning is that the node has a pane title, and was removed from the node hierarchy. It will also be sent if the pane title is set to null after it contained a title. No source will be returned if the node is no longer on the screen. To make the change more clear for the user, the first entry in getText() will return the value that would have been returned by getSource().getPaneTitle().

Value: 32

CONTENT_CHANGE_TYPE_PANE_TITLE

Added in API level 28
static val CONTENT_CHANGE_TYPE_PANE_TITLE: Int

Change type for TYPE_WINDOW_STATE_CHANGED event: The node's pane title changed.

If this makes the pane appear, CONTENT_CHANGE_TYPE_PANE_APPEARED is sent instead. If this makes the pane disappear, CONTENT_CHANGE_TYPE_PANE_DISAPPEARED is sent.

Value: 8

CONTENT_CHANGE_TYPE_STATE_DESCRIPTION

Added in API level 30
static val CONTENT_CHANGE_TYPE_STATE_DESCRIPTION: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: state description of the node as returned by AccessibilityNodeInfo#getStateDescription changed. If part of the state description changes, the changed part can be put into event text. For example, if state description changed from "on, wifi signal full" to "on, wifi three bars", "wifi three bars" can be put into the event text.

Value: 64

CONTENT_CHANGE_TYPE_SUBTREE

Added in API level 19
static val CONTENT_CHANGE_TYPE_SUBTREE: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: One or more content changes occurred in the the subtree rooted at the source node, or the subtree's structure changed when a node was added or removed.

Value: 1

CONTENT_CHANGE_TYPE_TEXT

Added in API level 19
static val CONTENT_CHANGE_TYPE_TEXT: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The node's text changed.

Value: 2

CONTENT_CHANGE_TYPE_UNDEFINED

Added in API level 19
static val CONTENT_CHANGE_TYPE_UNDEFINED: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: The type of change is not defined.

Value: 0

INVALID_POSITION

Added in API level 4
static val INVALID_POSITION: Int

Invalid selection/focus position.

Value: -1

MAX_TEXT_LENGTH

Added in API level 4
Deprecated in API level 15
static val MAX_TEXT_LENGTH: Int

Deprecated: Deprecated in Java.

Maximum length of the text fields.

Value: 500

SPEECH_STATE_LISTENING_END

Added in API level 33
static val SPEECH_STATE_LISTENING_END: Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is no longer listening to the microphone.

Value: 8

SPEECH_STATE_LISTENING_START

Added in API level 33
static val SPEECH_STATE_LISTENING_START: Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is listening to the microphone.

Value: 4

SPEECH_STATE_SPEAKING_END

Added in API level 33
static val SPEECH_STATE_SPEAKING_END: Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is no longer speaking.

Value: 2

SPEECH_STATE_SPEAKING_START

Added in API level 33
static val SPEECH_STATE_SPEAKING_START: Int

Change type for TYPE_SPEECH_STATE_CHANGE event: another service is speaking.

Value: 1

TYPE_ANNOUNCEMENT

Added in API level 16
static val TYPE_ANNOUNCEMENT: Int

Represents the event of an application making an announcement.

In general, follow the practices described in View#announceForAccessibility(CharSequence).

Value: 16384

TYPE_ASSIST_READING_CONTEXT

Added in API level 23
static val TYPE_ASSIST_READING_CONTEXT: Int

Represents the event of the assistant currently reading the users screen context.

Value: 16777216

TYPE_GESTURE_DETECTION_END

Added in API level 17
static val TYPE_GESTURE_DETECTION_END: Int

Represents the event of ending gesture detection.

Value: 524288

TYPE_GESTURE_DETECTION_START

Added in API level 17
static val TYPE_GESTURE_DETECTION_START: Int

Represents the event of beginning gesture detection.

Value: 262144

TYPE_NOTIFICATION_STATE_CHANGED

Added in API level 4
static val TYPE_NOTIFICATION_STATE_CHANGED: Int

Represents the event showing a android.app.Notification.

Value: 64

TYPE_SPEECH_STATE_CHANGE

Added in API level 33
static val TYPE_SPEECH_STATE_CHANGE: Int

Represents a change in the speech state defined by the speech state change types. A change in the speech state occurs when an application wants to signal that it is either speaking or listening for human speech. This event helps avoid conflicts where two applications want to speak or one listens when another speaks. When sending this event, the sender should ensure that the accompanying state change types make sense. For example, the sender should not send SPEECH_STATE_SPEAKING_START and SPEECH_STATE_SPEAKING_END together.

Value: 33554432

TYPE_TOUCH_EXPLORATION_GESTURE_END

Added in API level 14
static val TYPE_TOUCH_EXPLORATION_GESTURE_END: Int

Represents the event of ending a touch exploration gesture.

Value: 1024

TYPE_TOUCH_EXPLORATION_GESTURE_START

Added in API level 14
static val TYPE_TOUCH_EXPLORATION_GESTURE_START: Int

Represents the event of starting a touch exploration gesture.

Value: 512

TYPE_TOUCH_INTERACTION_END

Added in API level 17
static val TYPE_TOUCH_INTERACTION_END: Int

Represents the event of the user ending to touch the screen.

Value: 2097152

TYPE_TOUCH_INTERACTION_START

Added in API level 17
static val TYPE_TOUCH_INTERACTION_START: Int

Represents the event of the user starting to touch the screen.

Value: 1048576

TYPE_VIEW_ACCESSIBILITY_FOCUSED

Added in API level 16
static val TYPE_VIEW_ACCESSIBILITY_FOCUSED: Int

Represents the event of gaining accessibility focus.

Value: 32768

TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED

Added in API level 16
static val TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: Int

Represents the event of clearing accessibility focus.

Value: 65536

TYPE_VIEW_CLICKED

Added in API level 4
static val TYPE_VIEW_CLICKED: Int

Represents the event of clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc.

See AccessibilityNodeInfo.AccessibilityAction#ACTION_CLICK for more details.

Value: 1

TYPE_VIEW_CONTEXT_CLICKED

Added in API level 23
static val TYPE_VIEW_CONTEXT_CLICKED: Int

Represents the event of a context click on a android.view.View.

See AccessibilityNodeInfo.AccessibilityAction#ACTION_CONTEXT_CLICK for more details.

Value: 8388608

TYPE_VIEW_FOCUSED

Added in API level 4
static val TYPE_VIEW_FOCUSED: Int

Represents the event of setting input focus of a android.view.View.

Value: 8

TYPE_VIEW_HOVER_ENTER

Added in API level 14
static val TYPE_VIEW_HOVER_ENTER: Int

Represents the event of a hover enter over a android.view.View.

Value: 128

TYPE_VIEW_HOVER_EXIT

Added in API level 14
static val TYPE_VIEW_HOVER_EXIT: Int

Represents the event of a hover exit over a android.view.View.

Value: 256

TYPE_VIEW_LONG_CLICKED

Added in API level 4
static val TYPE_VIEW_LONG_CLICKED: Int

Represents the event of long clicking on a android.view.View like android.widget.Button, android.widget.CompoundButton, etc.

See AccessibilityNodeInfo.AccessibilityAction#ACTION_LONG_CLICK for more details.

Value: 2

TYPE_VIEW_SCROLLED

Added in API level 14
static val TYPE_VIEW_SCROLLED: Int

Represents the event of scrolling a view. This event type is generally not sent directly. In the View system, this is sent in android.view.View#onScrollChanged(int, int, int, int)

In addition to the source and package name, the event should populate scroll-specific properties like setScrollDeltaX(int), setScrollDeltaY(int), setMaxScrollX(int), and setMaxScrollY(int).

Services are encouraged to rely on the source to query UI state over AccessibilityEvents properties. For example, to check after a scroll if the bottom of the scrolling UI element has been reached, check if the source node is scrollable and has the AccessibilityNodeInfo.AccessibilityAction#ACTION_SCROLL_BACKWARD action but not the AccessibilityNodeInfo.AccessibilityAction#ACTION_SCROLL_FORWARD action. For scrolling to a target, use TYPE_VIEW_TARGETED_BY_SCROLL.

Value: 4096

TYPE_VIEW_SELECTED

Added in API level 4
static val TYPE_VIEW_SELECTED: Int

Represents the event of selecting an item usually in the context of an android.widget.AdapterView.

Value: 4

TYPE_VIEW_TARGETED_BY_SCROLL

Added in API level 34
static val TYPE_VIEW_TARGETED_BY_SCROLL: Int

Represents the event of a scroll having completed and brought the target node on screen.

Value: 67108864

TYPE_VIEW_TEXT_CHANGED

Added in API level 4
static val TYPE_VIEW_TEXT_CHANGED: Int

Represents the event of changing the text of an android.widget.EditText.

Value: 16

TYPE_VIEW_TEXT_SELECTION_CHANGED

Added in API level 14
static val TYPE_VIEW_TEXT_SELECTION_CHANGED: Int

Represents the event of changing the selection in an android.widget.EditText.

Value: 8192

TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY

Added in API level 16
static val TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: Int

Represents the event of traversing the text of a view at a given movement granularity.

Value: 131072

TYPE_WINDOWS_CHANGED

Added in API level 21
static val TYPE_WINDOWS_CHANGED: Int

Represents the event change in the system windows shown on the screen. This event type should only be dispatched by the system.

Value: 4194304

TYPE_WINDOW_CONTENT_CHANGED

Added in API level 14
static val TYPE_WINDOW_CONTENT_CHANGED: Int

Represents the event of changing the content of a window and more specifically the sub-tree rooted at the event's source.

Value: 2048

TYPE_WINDOW_STATE_CHANGED

Added in API level 4
static val TYPE_WINDOW_STATE_CHANGED: Int

Represents the event of a change to a visually distinct section of the user interface.

These events should only be dispatched from android.view.Views that have accessibility pane titles, and replaces TYPE_WINDOW_CONTENT_CHANGED for those sources. Details about the change are available from getContentChangeTypes().

Do not use this to get an accessibility service to make non-pane announcements. Instead, follow the practices described in View#announceForAccessibility(CharSequence). Note: this does not suggest calling announceForAccessibility(), but using the suggestions listed in its documentation.

Value: 32

WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED

Added in API level 28
static val WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isAccessibilityFocused() changed.

Value: 128

WINDOWS_CHANGE_ACTIVE

Added in API level 28
static val WINDOWS_CHANGE_ACTIVE: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isActive() changed.

Value: 32

WINDOWS_CHANGE_ADDED

Added in API level 28
static val WINDOWS_CHANGE_ADDED: Int

Change type for TYPE_WINDOWS_CHANGED event: The window was added.

Value: 1

WINDOWS_CHANGE_BOUNDS

Added in API level 28
static val WINDOWS_CHANGE_BOUNDS: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's bounds changed.

Starting in R, this event implies the window's region changed. It's also possible that region changed but bounds doesn't.

Value: 8

WINDOWS_CHANGE_CHILDREN

Added in API level 28
static val WINDOWS_CHANGE_CHILDREN: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's children changed.

Value: 512

WINDOWS_CHANGE_FOCUSED

Added in API level 28
static val WINDOWS_CHANGE_FOCUSED: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's AccessibilityWindowInfo#isFocused() changed.

Value: 64

WINDOWS_CHANGE_LAYER

Added in API level 28
static val WINDOWS_CHANGE_LAYER: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's layer changed.

Value: 16

WINDOWS_CHANGE_PARENT

Added in API level 28
static val WINDOWS_CHANGE_PARENT: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's parent changed.

Value: 256

WINDOWS_CHANGE_PIP

Added in API level 28
static val WINDOWS_CHANGE_PIP: Int

Change type for TYPE_WINDOWS_CHANGED event: The window either entered or exited picture-in-picture mode.

Value: 1024

WINDOWS_CHANGE_REMOVED

Added in API level 28
static val WINDOWS_CHANGE_REMOVED: Int

Change type for TYPE_WINDOWS_CHANGED event: A window was removed.

Value: 2

WINDOWS_CHANGE_TITLE

Added in API level 28
static val WINDOWS_CHANGE_TITLE: Int

Change type for TYPE_WINDOWS_CHANGED event: The window's title changed.

Value: 4

Public constructors

AccessibilityEvent

Added in API level 4
AccessibilityEvent()

Creates a new AccessibilityEvent.

AccessibilityEvent

Added in API level 4
AccessibilityEvent(eventType: Int)

Creates a new AccessibilityEvent with the given eventType.

Parameters
eventType Int: The event type.

AccessibilityEvent

Added in API level 4
AccessibilityEvent(event: AccessibilityEvent)

Copy constructor. Creates a new AccessibilityEvent, and this instance is initialized from the given event.

Parameters
event AccessibilityEvent: The other event. This value cannot be null.

Public methods

appendRecord

Added in API level 14
fun appendRecord(record: AccessibilityRecord!): Unit

Appends an AccessibilityRecord to the end of event records.

Parameters
record AccessibilityRecord!: The record to append.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

describeContents

Added in API level 4
fun describeContents(): Int

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.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

eventTypeToString

Added in API level 14
static fun eventTypeToString(eventType: Int): String!

Returns the string representation of an event type. For example, TYPE_VIEW_CLICKED is represented by the string TYPE_VIEW_CLICKED.

Parameters
eventType Int: The event type
Return
String! The string representation.

getAction

Added in API level 16
fun getAction(): Int

Gets the performed action that triggered this event.

Return
Int The action.

getContentChangeTypes

Added in API level 19
fun getContentChangeTypes(): Int

Gets the bit mask of change types signaled by a TYPE_WINDOW_CONTENT_CHANGED event or TYPE_WINDOW_STATE_CHANGED. A single event may represent multiple change types.

Return
Int The bit mask of change types. One or more of: Value is either 0 or a combination of android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_TITLE, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_APPEARED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_DISAPPEARED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_STARTED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_DROPPED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_CANCELLED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_INVALID, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR, and android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_ENABLED

getEventTime

Added in API level 4
fun getEventTime(): Long

Gets the time in which this event was sent.

Return
Long The event time.

getEventType

Added in API level 4
fun getEventType(): Int

Gets the event type.

Return
Int The event type. Value is either 0 or a combination of android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_LONG_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SELECTED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_FOCUSED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_EXIT, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_START, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END, android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SCROLLED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_SELECTION_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_ANNOUNCEMENT, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUSED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY, android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_START, android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_END, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_START, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_END, android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CONTEXT_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_ASSIST_READING_CONTEXT, android.view.accessibility.AccessibilityEvent#TYPE_SPEECH_STATE_CHANGE, and android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TARGETED_BY_SCROLL

getMovementGranularity

Added in API level 16
fun getMovementGranularity(): Int

Gets the movement granularity that was traversed.

Return
Int The granularity.

getPackageName

Added in API level 4
fun getPackageName(): CharSequence!

Gets the package name of the source.

Return
CharSequence! The package name.

getRecord

Added in API level 14
fun getRecord(index: Int): AccessibilityRecord!

Gets the record at a given index.

Parameters
index Int: The index.
Return
AccessibilityRecord! The record at the specified index.

getRecordCount

Added in API level 14
fun getRecordCount(): Int

Gets the number of records contained in the event.

Return
Int The number of records.

getSpeechStateChangeTypes

Added in API level 33
fun getSpeechStateChangeTypes(): Int

Gets the bit mask of the speech state signaled by a TYPE_SPEECH_STATE_CHANGE event.

Return
Int The bit mask of speech change types.

initFromParcel

Added in API level 4
fun initFromParcel(parcel: Parcel!): Unit

Creates a new instance from a Parcel.

Parameters
parcel Parcel!: A parcel containing the state of a AccessibilityEvent.

isAccessibilityDataSensitive

Added in API level 34
fun isAccessibilityDataSensitive(): Boolean

Whether the event should only be delivered to an android.accessibilityservice.AccessibilityService with the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.

Initial value matches the android.view.View#isAccessibilityDataSensitive property from the event's source node, if present, or false by default.

Return
Boolean True if the event should be delivered only to isAccessibilityTool services, false otherwise.

obtain

Added in API level 4
Deprecated in API level 33
static fun obtain(eventType: Int): AccessibilityEvent!

Deprecated: Object pooling has been discontinued. Create a new instance using the constructor AccessibilityEvent() instead.

Instantiates a new AccessibilityEvent instance with its type property set.

Parameters
eventType Int: The event type.
Return
AccessibilityEvent! An instance.

obtain

Added in API level 14
Deprecated in API level 33
static fun obtain(event: AccessibilityEvent!): AccessibilityEvent!

Deprecated: Object pooling has been discontinued. Create a new instance using the constructor AccessibilityEvent() instead.

Instantiates a new AccessibilityEvent instance. The returned instance is initialized from the given event.

Parameters
event AccessibilityEvent!: The other event.
Return
AccessibilityEvent! An instance.

obtain

Added in API level 4
Deprecated in API level 33
static fun obtain(): AccessibilityEvent!

Deprecated: Object pooling has been discontinued. Create a new instance using the constructor AccessibilityEvent() instead.

Instantiates a new AccessibilityEvent instance.

Return
AccessibilityEvent! An instance.

recycle

Added in API level 4
Deprecated in API level 33
fun recycle(): Unit

Deprecated: Object pooling has been discontinued. Calling this function now will have no effect.

Previously would recycle an instance back to be reused.

setAccessibilityDataSensitive

Added in API level 34
fun setAccessibilityDataSensitive(accessibilityDataSensitive: Boolean): Unit

Sets whether the event should only be delivered to an android.accessibilityservice.AccessibilityService with the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.

This will be set automatically based on the event's source (if present). If creating and sending an event directly through AccessibilityManager (where an event may have no source) then this method must be called explicitly if you want non-default behavior.

Parameters
accessibilityDataSensitive Boolean: True if the event should be delivered only to isAccessibilityTool services, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setContentChangeTypes

Added in API level 19
fun setContentChangeTypes(changeTypes: Int): Unit

Sets the bit mask of node tree changes signaled by an TYPE_WINDOW_CONTENT_CHANGED event.

Parameters
changeTypes Int: The bit mask of change types. Value is either 0 or a combination of android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_TITLE, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_APPEARED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_PANE_DISAPPEARED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_STARTED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_DROPPED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_CANCELLED, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_INVALID, android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR, and android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_ENABLED
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setEventTime

Added in API level 4
fun setEventTime(eventTime: Long): Unit

Sets the time in which this event was sent.

Parameters
eventTime Long: The event time.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setEventType

Added in API level 4
fun setEventType(eventType: Int): Unit

Sets the event type. Note: An event must represent a single event type.

Parameters
eventType Int: The event type. Value is either 0 or a combination of android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_LONG_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SELECTED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_FOCUSED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_EXIT, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_START, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END, android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SCROLLED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_SELECTION_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_ANNOUNCEMENT, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUSED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY, android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_START, android.view.accessibility.AccessibilityEvent#TYPE_GESTURE_DETECTION_END, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_START, android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_END, android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED, android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CONTEXT_CLICKED, android.view.accessibility.AccessibilityEvent#TYPE_ASSIST_READING_CONTEXT, android.view.accessibility.AccessibilityEvent#TYPE_SPEECH_STATE_CHANGE, and android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TARGETED_BY_SCROLL
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setMovementGranularity

Added in API level 16
fun setMovementGranularity(granularity: Int): Unit

Sets the movement granularity that was traversed.

Parameters
granularity Int: The granularity.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setPackageName

Added in API level 4
fun setPackageName(packageName: CharSequence!): Unit

Sets the package name of the source.

Parameters
packageName CharSequence!: The package name.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setSpeechStateChangeTypes

Added in API level 33
fun setSpeechStateChangeTypes(state: Int): Unit

Sets the bit mask of the speech state change types signaled by a TYPE_SPEECH_STATE_CHANGE event. The sender is responsible for ensuring that the state change types make sense. For example, the sender should not send SPEECH_STATE_SPEAKING_START and SPEECH_STATE_SPEAKING_END together.

Parameters
state Int: Value is either 0 or a combination of android.view.accessibility.AccessibilityEvent#SPEECH_STATE_SPEAKING_START, android.view.accessibility.AccessibilityEvent#SPEECH_STATE_SPEAKING_END, android.view.accessibility.AccessibilityEvent#SPEECH_STATE_LISTENING_START, and android.view.accessibility.AccessibilityEvent#SPEECH_STATE_LISTENING_END

toString

Added in API level 4
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 4
fun writeToParcel(
    parcel: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 4
static val CREATOR: Parcelable.Creator<AccessibilityEvent!>