AccessibilityEventCompat

Added in 1.1.0

class AccessibilityEventCompat


Helper for accessing features in AccessibilityEvent.

Summary

Constants

const Int

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

const Int

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

const Int

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

const Int

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

const Int

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

const Int

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

const Int

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

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

const Int

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

const Int

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

const Int

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

const Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A node in the subtree rooted at the source node was added or removed.

const Int

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

const Int

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

const Int

Mask for AccessibilityEvent all types.

const Int

Represents the event of an application making an announcement.

const Int

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

const Int

Represents the event of ending gesture detection.

const Int

Represents the event of beginning gesture detection.

const Int

This property is deprecated.

Use TYPE_TOUCH_EXPLORATION_GESTURE_END directly.

const Int

This property is deprecated.

Use TYPE_TOUCH_EXPLORATION_GESTURE_START directly.

const Int

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

const Int

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

const Int

Represents the event of gaining accessibility focus.

const Int

Represents the event of clearing accessibility focus.

const Int

Represents the event of a context click on a View.

const Int

This property is deprecated.

Use TYPE_VIEW_HOVER_ENTER directly.

const Int

This property is deprecated.

Use TYPE_VIEW_HOVER_EXIT directly.

const Int

This property is deprecated.

Use TYPE_VIEW_SCROLLED directly.

const Int

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

const Int

This property is deprecated.

Use TYPE_VIEW_TEXT_SELECTION_CHANGED directly.

const Int

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

const Int

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

const Int

This property is deprecated.

Use TYPE_WINDOW_CONTENT_CHANGED directly.

Public functions

java-static Unit
appendRecord(
    event: AccessibilityEvent!,
    record: AccessibilityRecordCompat!
)

This function is deprecated.

Use appendRecord directly.

java-static AccessibilityRecordCompat!

This function is deprecated.

Use the AccessibilityEvent directly as AccessibilityRecord.

java-static Int

Gets the performed action that triggered this event.

java-static Int

Gets the bit mask of change types signaled by an TYPE_WINDOW_CONTENT_CHANGED event.

java-static Int

Gets the movement granularity that was traversed.

java-static AccessibilityRecordCompat!
getRecord(event: AccessibilityEvent!, index: Int)

This function is deprecated.

Use getRecord directly.

java-static Int

This function is deprecated.

Use getRecordCount directly.

java-static Boolean

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

java-static Unit
setAccessibilityDataSensitive(
    event: AccessibilityEvent,
    accessibilityDataSensitive: Boolean
)

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

java-static Unit
setAction(event: AccessibilityEvent, action: Int)

Sets the performed action that triggered this event.

java-static Unit

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

java-static Unit

Sets the movement granularity that was traversed.

Constants

CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = 4: Int

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

CONTENT_CHANGE_TYPE_CONTENT_INVALID

Added in 1.12.0
const val CONTENT_CHANGE_TYPE_CONTENT_INVALID = 1024: Int

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

CONTENT_CHANGE_TYPE_DRAG_CANCELLED

Added in 1.9.0
const val CONTENT_CHANGE_TYPE_DRAG_CANCELLED = 512: 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.

CONTENT_CHANGE_TYPE_DRAG_DROPPED

Added in 1.9.0
const val CONTENT_CHANGE_TYPE_DRAG_DROPPED = 256: 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.

See also
ACTION_DRAG_DROP

CONTENT_CHANGE_TYPE_DRAG_STARTED

Added in 1.9.0
const val CONTENT_CHANGE_TYPE_DRAG_STARTED = 128: 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.

CONTENT_CHANGE_TYPE_ENABLED

Added in 1.12.0
const val CONTENT_CHANGE_TYPE_ENABLED = 4096: Int

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

CONTENT_CHANGE_TYPE_ERROR

Added in 1.12.0
const val CONTENT_CHANGE_TYPE_ERROR = 2048: Int

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

See also
getError
setError

CONTENT_CHANGE_TYPE_PANE_APPEARED

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_PANE_APPEARED = 16: 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.

CONTENT_CHANGE_TYPE_PANE_DISAPPEARED

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_PANE_DISAPPEARED = 32: 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 can 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 can return the value that would have been returned by getSource().getPaneTitle().

CONTENT_CHANGE_TYPE_PANE_TITLE

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_PANE_TITLE = 8: Int

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

CONTENT_CHANGE_TYPE_STATE_DESCRIPTION

Added in 1.5.0
const val CONTENT_CHANGE_TYPE_STATE_DESCRIPTION = 64: Int

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

CONTENT_CHANGE_TYPE_SUBTREE

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_SUBTREE = 1: Int

Change type for TYPE_WINDOW_CONTENT_CHANGED event: A node in the subtree rooted at the source node was added or removed.

CONTENT_CHANGE_TYPE_TEXT

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_TEXT = 2: Int

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

CONTENT_CHANGE_TYPE_UNDEFINED

Added in 1.1.0
const val CONTENT_CHANGE_TYPE_UNDEFINED = 0: Int

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

TYPE_ANNOUNCEMENT

Added in 1.1.0
const val TYPE_ANNOUNCEMENT = 16384: Int

Represents the event of an application making an announcement.

Note: This event carries no semantic meaning and is appropriate only in exceptional situations. Apps can generally achieve correct behavior for accessibility by accurately supplying the semantics of their UI. They should not need to specify what exactly is announced to users.

In general, only announce transitions that can't be handled by the following preferred alternatives:

  • Label your controls concisely and precisely. Don’t generate a confirmation message for simple actions like a button press.
  • For significant UI changes like window changes, use setTitle and setAccessibilityPaneTitle )}.
  • Use setAccessibilityLiveRegion to inform the user of changes to critical views within the user interface. These should still be used sparingly as they may generate announcements every time a View is updated.

TYPE_ASSIST_READING_CONTEXT

Added in 1.1.0
const val TYPE_ASSIST_READING_CONTEXT = 16777216: Int

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

TYPE_GESTURE_DETECTION_END

Added in 1.1.0
const val TYPE_GESTURE_DETECTION_END = 524288: Int

Represents the event of ending gesture detection.

TYPE_GESTURE_DETECTION_START

Added in 1.1.0
const val TYPE_GESTURE_DETECTION_START = 262144: Int

Represents the event of beginning gesture detection.

TYPE_TOUCH_EXPLORATION_GESTURE_END

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_TOUCH_EXPLORATION_GESTURE_END = 1024: Int

Represents the event of ending a touch exploration gesture.

TYPE_TOUCH_EXPLORATION_GESTURE_START

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_TOUCH_EXPLORATION_GESTURE_START = 512: Int

Represents the event of starting a touch exploration gesture.

TYPE_TOUCH_INTERACTION_END

Added in 1.1.0
const val TYPE_TOUCH_INTERACTION_END = 2097152: Int

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

TYPE_TOUCH_INTERACTION_START

Added in 1.1.0
const val TYPE_TOUCH_INTERACTION_START = 1048576: Int

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

TYPE_VIEW_ACCESSIBILITY_FOCUSED

Added in 1.1.0
const val TYPE_VIEW_ACCESSIBILITY_FOCUSED = 32768: Int

Represents the event of gaining accessibility focus.

TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED

Added in 1.1.0
const val TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 65536: Int

Represents the event of clearing accessibility focus.

TYPE_VIEW_CONTEXT_CLICKED

Added in 1.1.0
const val TYPE_VIEW_CONTEXT_CLICKED = 8388608: Int

Represents the event of a context click on a View.

TYPE_VIEW_HOVER_ENTER

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_VIEW_HOVER_ENTER = 128: Int

Represents the event of a hover enter over a View.

TYPE_VIEW_HOVER_EXIT

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_VIEW_HOVER_EXIT = 256: Int

Represents the event of a hover exit over a View.

TYPE_VIEW_SCROLLED

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_VIEW_SCROLLED = 4096: Int

Represents the event of scrolling a view.

TYPE_VIEW_TARGETED_BY_SCROLL

Added in 1.12.0
const val TYPE_VIEW_TARGETED_BY_SCROLL = 67108864: Int

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

TYPE_VIEW_TEXT_SELECTION_CHANGED

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_VIEW_TEXT_SELECTION_CHANGED = 8192: Int

Represents the event of changing the selection in an EditText.

TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY

Added in 1.1.0
const val TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 131072: Int

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

TYPE_WINDOWS_CHANGED

Added in 1.1.0
const val TYPE_WINDOWS_CHANGED = 4194304: Int

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

TYPE_WINDOW_CONTENT_CHANGED

Added in 1.1.0
Deprecated in 1.1.0
const val TYPE_WINDOW_CONTENT_CHANGED = 2048: Int

Represents the event of changing the content of a window.

Public functions

appendRecord

Added in 1.1.0
Deprecated in 1.1.0
java-static fun appendRecord(
    event: AccessibilityEvent!,
    record: AccessibilityRecordCompat!
): Unit

Appends an AccessibilityRecord to the end of event records.

Parameters
event: AccessibilityEvent!

event for which to append the record.

record: AccessibilityRecordCompat!

The record to append.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

asRecord

Added in 1.1.0
Deprecated in 1.1.0
java-static fun asRecord(event: AccessibilityEvent!): AccessibilityRecordCompat!

Creates an AccessibilityRecordCompat from an AccessibilityEvent that can be used to manipulate the event properties defined in AccessibilityRecord.

Note: Do not call recycle on the returned AccessibilityRecordCompat. Call recycle in case you want to recycle the event.

Parameters
event: AccessibilityEvent!

The from which to create a record.

getAction

Added in 1.1.0
java-static fun getAction(event: AccessibilityEvent): Int

Gets the performed action that triggered this event.

Returns
Int

The action.

getContentChangeTypes

Added in 1.1.0
java-static fun getContentChangeTypes(event: AccessibilityEvent): Int

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

getMovementGranularity

Added in 1.1.0
java-static fun getMovementGranularity(event: AccessibilityEvent): Int

Gets the movement granularity that was traversed.

Returns
Int

The granularity.

getRecord

Added in 1.1.0
Deprecated in 1.1.0
java-static fun getRecord(event: AccessibilityEvent!, index: Int): AccessibilityRecordCompat!

Gets the record at a given index.

Parameters
event: AccessibilityEvent!

event for which to get the record.

index: Int

The index.

Returns
AccessibilityRecordCompat!

The record at the specified index.

getRecordCount

Added in 1.1.0
Deprecated in 1.1.0
java-static fun getRecordCount(event: AccessibilityEvent!): Int

Gets the number of records contained in the event.

Returns
Int

The number of records.

isAccessibilityDataSensitive

Added in 1.12.0
java-static fun isAccessibilityDataSensitive(event: AccessibilityEvent): Boolean

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

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

Returns
Boolean

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

setAccessibilityDataSensitive

Added in 1.12.0
java-static fun setAccessibilityDataSensitive(
    event: AccessibilityEvent,
    accessibilityDataSensitive: Boolean
): Unit

Sets whether the event should only be delivered to an android.accessibilityservice.AccessibilityService with the 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 android.view.accessibility.AccessibilityManager (where an event may have no source) then this method must be called explicitly if you want non-default behavior.

Parameters
event: AccessibilityEvent

The event to update.

accessibilityDataSensitive: Boolean

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

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setAction

Added in 1.1.0
java-static fun setAction(event: AccessibilityEvent, action: Int): Unit

Sets the performed action that triggered this event.

Valid actions are defined in AccessibilityNodeInfoCompat:

Parameters
event: AccessibilityEvent

event for which to set the action.

action: Int

The action.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

See also
performAction

setContentChangeTypes

Added in 1.1.0
java-static fun setContentChangeTypes(event: AccessibilityEvent, changeTypes: Int): Unit

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

Parameters
event: AccessibilityEvent

event for which to set the types.

changeTypes: Int

The bit mask of change types.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.

setMovementGranularity

Added in 1.1.0
java-static fun setMovementGranularity(event: AccessibilityEvent, granularity: Int): Unit

Sets the movement granularity that was traversed.

Parameters
event: AccessibilityEvent

event for which to set the granularity.

granularity: Int

The granularity.

Throws
java.lang.IllegalStateException

If called from an AccessibilityService.