java.lang.Object | ||
↳ | 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
Button
is clicked, a 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 add an AccessibilityRecord
for itself before
dispatching a similar request to its parent. A parent can also choose not to respect the
request for sending an event. The accessibility event is sent by the topmost view in the
view tree. Therefore, an AccessibilityService
can
explore all records in an accessibility event to obtain more information about the
context in which the event was fired.
The main purpose of an accessibility event is to expose enough information for an
AccessibilityService
to provide meaningful feedback
to the user. Sometimes however, an accessibility service may need more contextual
information then the one in the event pay-load. In such cases the service can obtain
the event source which is an AccessibilityNodeInfo
(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 AccessibilityService
. If an
accessibility service has not requested to retrieve the window content the event will
not contain reference to its source. Also for events of type
TYPE_NOTIFICATION_STATE_CHANGED
the source is never available.
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:
For more information about creating and processing AccessibilityEvents, read the Accessibility developer guide.
VIEW TYPES
View clicked - represents the event of clicking on a View
like Button
, CompoundButton
, etc.
Type:TYPE_VIEW_CLICKED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.isPassword()
- Whether the source is password.isChecked()
- Whether the source is checked.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).
View long clicked - represents the event of long clicking on a View
like Button
, CompoundButton
, etc
Type:TYPE_VIEW_LONG_CLICKED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.isPassword()
- Whether the source is password.isChecked()
- Whether the source is checked.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).
View selected - represents the event of selecting an item usually in
the context of an AdapterView
.
Type: TYPE_VIEW_SELECTED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.isPassword()
- Whether the source is password.isChecked()
- Whether the source is checked.getItemCount()
- The number of selectable items of the source.getCurrentItemIndex()
- The currently selected item index.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).
View focused - represents the event of focusing a
View
.
Type: TYPE_VIEW_FOCUSED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.isPassword()
- Whether the source is password.isChecked()
- Whether the source is checked.getItemCount()
- The number of focusable items on the screen.getCurrentItemIndex()
- The currently focused item index.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).
View text changed - represents the event of changing the text of an
EditText
.
Type: TYPE_VIEW_TEXT_CHANGED
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.getText()
- The text of the source.isEnabled()
- Whether the source is enabled.isPassword()
- Whether the source is password.isChecked()
- Whether the source is checked.getFromIndex()
- The text change start index.getAddedCount()
- The number of added characters.getRemovedCount()
- The number of removed characters.getBeforeText()
- The text of the source before the change.getContentDescription()
- The content description of the source.
View text selection changed - represents the event of changing the text
selection of an EditText
.
Type: TYPE_VIEW_TEXT_SELECTION_CHANGED
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.getText()
- The text of the source.isPassword()
- Whether the source is password.getFromIndex()
- The selection start index.getToIndex()
- The selection end index.getItemCount()
- The length of the source text.isEnabled()
- Whether the source is enabled.getContentDescription()
- The content description of the source.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 of the next/previous text at the specified granularity
- inclusive.getToIndex()
- The end of the next/previous text at the specified granularity
- exclusive.isPassword()
- Whether the source is password.isEnabled()
- Whether the source is enabled.getContentDescription()
- The content description of the source.getMovementGranularity()
- Sets the granularity at which a view's text
was traversed.getAction()
- Gets traversal action which specifies the direction.
View scrolled - represents the event of scrolling a view. If
the source is a descendant of AdapterView
the
scroll is reported in terms of visible items - the first visible item,
the last visible item, and the total items - because the the source
is unaware of its pixel size since its adapter is responsible for
creating views. In all other cases the scroll is reported as the current
scroll on the X and Y axis respectively plus the height of the source in
pixels.
Type: TYPE_VIEW_SCROLLED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
, hence the event
source View
and the sub-tree rooted at it will not receive
calls to View.onPopulateAccessibilityEvent(AccessibilityEvent)
. The preferred way to add
text content to such events is by setting the
contentDescription
of the source
view.
TRANSITION TYPES
Window state changed - represents the event of opening a
PopupWindow
, Menu
,
Dialog
, etc.
Type: TYPE_WINDOW_STATE_CHANGED
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.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.
Note: This event is fired only for the window source of the
last accessibility event different from TYPE_NOTIFICATION_STATE_CHANGED
and its purpose is to notify clients that the content of the user interaction
window has changed.
Type: TYPE_WINDOW_CONTENT_CHANGED
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.View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
, hence the event
source View
and the sub-tree rooted at it will not receive
calls to View.onPopulateAccessibilityEvent(AccessibilityEvent)
. The preferred way to add
text content to such events is by setting the
contentDescription
of the source
view.
NOTIFICATION TYPES
Notification state changed - represents the event showing
Notification
.
Type: TYPE_NOTIFICATION_STATE_CHANGED
Properties:
getEventType()
- The type of the event.getClassName()
- The class name of the source.getPackageName()
- The package name of the source.getEventTime()
- The event time.getText()
- The text of the source's sub-tree.getParcelableData()
- The posted Notification
.getText()
- Text for providing more context.View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
, hence the event
source View
and the sub-tree rooted at it will not receive
calls to View.onPopulateAccessibilityEvent(AccessibilityEvent)
. The preferred way to add
text content to such events is by setting the
contentDescription
of the source
view.
EXPLORATION TYPES
View hover enter - represents the event of beginning to hover
over a View
. The hover may be generated via
exploring the screen by touch or via a pointing device.
Type: TYPE_VIEW_HOVER_ENTER
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).View
. The hover may be generated via
exploring the screen by touch or via a pointing device.
Type: TYPE_VIEW_HOVER_EXIT
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.getText()
- The text of the source's sub-tree.isEnabled()
- Whether the source is enabled.getContentDescription()
- The content description of the source.getScrollX()
- The offset of the source left edge in pixels
(without descendants of AdapterView).getScrollY()
- The offset of the source top edge in pixels
(without descendants of AdapterView).getFromIndex()
- The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).getToIndex()
- The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).getItemCount()
- The total items of the source
(for descendants of AdapterView).
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:
getEventType()
- The type of the event.
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:
getEventType()
- The type of the event.
Touch exploration gesture start - represents the event of starting a touch
exploring gesture.
Type: TYPE_TOUCH_EXPLORATION_GESTURE_START
Properties:
getEventType()
- The type of the event.
Touch exploration gesture end - represents the event of ending a touch
exploring gesture.
Type: TYPE_TOUCH_EXPLORATION_GESTURE_END
Properties:
getEventType()
- The type of the event.
Touch gesture detection start - represents the event of starting a user
gesture detection.
Type: TYPE_GESTURE_DETECTION_START
Properties:
getEventType()
- The type of the event.
Touch gesture detection end - represents the event of ending a user
gesture detection.
Type: TYPE_GESTURE_DETECTION_END
Properties:
getEventType()
- The type of the event.MISCELLANEOUS TYPES
Announcement - represents the event of an application making an
announcement. Usually this announcement is related to some sort of a context
change for which none of the events representing UI transitions is a good fit.
For example, announcing a new page in a book.
Type: TYPE_ANNOUNCEMENT
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.getText()
- The text of the announcement.isEnabled()
- Whether the source is enabled.Security note
Since an event contains the text of its source privacy can be compromised by leaking sensitive information such as passwords. To address this issue any event fired in response to manipulation of a PASSWORD field does NOT CONTAIN the text of the password.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INVALID_POSITION | Invalid selection/focus position. | |||||||||
int | MAX_TEXT_LENGTH | Maximum length of the text fields. | |||||||||
int | TYPES_ALL_MASK | Mask for AccessibilityEvent all types. |
|||||||||
int | TYPE_ANNOUNCEMENT | Represents the event of an application making an announcement. | |||||||||
int | TYPE_GESTURE_DETECTION_END | Represents the event of ending gesture detection. | |||||||||
int | TYPE_GESTURE_DETECTION_START | Represents the event of beginning gesture detection. | |||||||||
int | TYPE_NOTIFICATION_STATE_CHANGED | Represents the event showing a Notification . |
|||||||||
int | TYPE_TOUCH_EXPLORATION_GESTURE_END | Represents the event of ending a touch exploration gesture. | |||||||||
int | TYPE_TOUCH_EXPLORATION_GESTURE_START | Represents the event of starting a touch exploration gesture. | |||||||||
int | TYPE_TOUCH_INTERACTION_END | Represents the event of the user ending to touch the screen. | |||||||||
int | TYPE_TOUCH_INTERACTION_START | Represents the event of the user starting to touch the screen. | |||||||||
int | TYPE_VIEW_ACCESSIBILITY_FOCUSED | Represents the event of gaining accessibility focus. | |||||||||
int | TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED | Represents the event of clearing accessibility focus. | |||||||||
int | TYPE_VIEW_CLICKED | Represents the event of clicking on a View like
Button , CompoundButton , etc. |
|||||||||
int | TYPE_VIEW_FOCUSED | Represents the event of setting input focus of a View . |
|||||||||
int | TYPE_VIEW_HOVER_ENTER | Represents the event of a hover enter over a View . |
|||||||||
int | TYPE_VIEW_HOVER_EXIT | Represents the event of a hover exit over a View . |
|||||||||
int | TYPE_VIEW_LONG_CLICKED | Represents the event of long clicking on a View like
Button , CompoundButton , etc. |
|||||||||
int | TYPE_VIEW_SCROLLED | Represents the event of scrolling a view. | |||||||||
int | TYPE_VIEW_SELECTED | Represents the event of selecting an item usually in the context of an
AdapterView . |
|||||||||
int | TYPE_VIEW_TEXT_CHANGED | Represents the event of changing the text of an EditText . |
|||||||||
int | TYPE_VIEW_TEXT_SELECTION_CHANGED | Represents the event of changing the selection in an EditText . |
|||||||||
int | TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY | Represents the event of traversing the text of a view at a given movement granularity. | |||||||||
int | TYPE_WINDOW_CONTENT_CHANGED | Represents the event of changing the content of a window and more specifically the sub-tree rooted at the event's source. | |||||||||
int | TYPE_WINDOW_STATE_CHANGED | Represents the event of opening a PopupWindow ,
Menu , Dialog , etc. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Appends an
AccessibilityRecord to the end of event records. | |||||||||||
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
| |||||||||||
Returns the string representation of an event type.
| |||||||||||
Gets the performed action that triggered this event.
| |||||||||||
Gets the time in which this event was sent.
| |||||||||||
Gets the event type.
| |||||||||||
Gets the movement granularity that was traversed.
| |||||||||||
Gets the package name of the source.
| |||||||||||
Gets the record at a given index.
| |||||||||||
Gets the number of records contained in the event.
| |||||||||||
Creates a new instance from a
Parcel . | |||||||||||
Returns a cached instance if such is available or a new one is
instantiated with its type property set.
| |||||||||||
Returns a cached instance if such is available or a new one is
instantiated.
| |||||||||||
Returns a cached instance if such is available or a new one is
created.
| |||||||||||
Recycles an instance back to be reused.
| |||||||||||
Sets the performed action that triggered this event.
| |||||||||||
Sets the time in which this event was sent.
| |||||||||||
Sets the event type.
| |||||||||||
Sets the movement granularity that was traversed.
| |||||||||||
Sets the package name of the source.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Flatten this object in to a Parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.accessibility.AccessibilityRecord
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
|
Maximum length of the text fields.
Mask for AccessibilityEvent
all types.
TYPE_VIEW_CLICKED
TYPE_VIEW_LONG_CLICKED
TYPE_VIEW_SELECTED
TYPE_VIEW_FOCUSED
TYPE_VIEW_TEXT_CHANGED
TYPE_WINDOW_STATE_CHANGED
TYPE_NOTIFICATION_STATE_CHANGED
TYPE_VIEW_HOVER_ENTER
TYPE_VIEW_HOVER_EXIT
TYPE_TOUCH_EXPLORATION_GESTURE_START
TYPE_TOUCH_EXPLORATION_GESTURE_END
TYPE_WINDOW_CONTENT_CHANGED
TYPE_VIEW_SCROLLED
TYPE_VIEW_TEXT_SELECTION_CHANGED
TYPE_ANNOUNCEMENT
TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
TYPE_GESTURE_DETECTION_START
TYPE_GESTURE_DETECTION_END
TYPE_TOUCH_INTERACTION_START
TYPE_TOUCH_INTERACTION_END
Represents the event of an application making an announcement.
Represents the event of ending gesture detection.
Represents the event of beginning gesture detection.
Represents the event showing a Notification
.
Represents the event of ending a touch exploration gesture.
Represents the event of starting a touch exploration gesture.
Represents the event of the user ending to touch the screen.
Represents the event of the user starting to touch the screen.
Represents the event of gaining accessibility focus.
Represents the event of clearing accessibility focus.
Represents the event of clicking on a View
like
Button
, CompoundButton
, etc.
Represents the event of setting input focus of a View
.
Represents the event of a hover enter over a View
.
Represents the event of a hover exit over a View
.
Represents the event of long clicking on a View
like
Button
, CompoundButton
, etc.
Represents the event of scrolling a view.
Represents the event of selecting an item usually in the context of an
AdapterView
.
Represents the event of changing the text of an EditText
.
Represents the event of changing the selection in an EditText
.
Represents the event of traversing the text of a view at a given movement granularity.
Represents the event of changing the content of a window and more specifically the sub-tree rooted at the event's source.
Represents the event of opening a PopupWindow
,
Menu
, Dialog
, etc.
Appends an AccessibilityRecord
to the end of event records.
record | The record to append. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Returns the string representation of an event type. For example,
TYPE_VIEW_CLICKED
is represented by the string TYPE_VIEW_CLICKED.
eventType | The event type |
---|
Gets the performed action that triggered this event.
Gets the time in which this event was sent.
Gets the movement granularity that was traversed.
Gets the package name of the source.
Gets the record at a given index.
index | The index. |
---|
Gets the number of records contained in the event.
Creates a new instance from a Parcel
.
parcel | A parcel containing the state of a AccessibilityEvent .
|
---|
Returns a cached instance if such is available or a new one is instantiated with its type property set.
eventType | The event type. |
---|
Returns a cached instance if such is available or a new one is instantiated.
Returns a cached instance if such is available or a new one is
created. The returned instance is initialized from the given
event
.
event | The other event. |
---|
Recycles an instance back to be reused.
Note: You must not touch the object after calling this function.
IllegalStateException | If the event is already recycled. |
---|
Sets the performed action that triggered this event.
action | The action. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
Sets the time in which this event was sent.
eventTime | The event time. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
Sets the event type.
eventType | The event type. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
Sets the movement granularity that was traversed.
granularity | The granularity. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
Sets the package name of the source.
packageName | The package name. |
---|
IllegalStateException | If called from an AccessibilityService. |
---|
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.
Flatten this object in to a Parcel.
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_WRITE_RETURN_VALUE .
|