This class represents accessibility events that are sent by the system when
something notable happens in the user interface. For example, when a
{@link android.widget.Button} is clicked, a {@link 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 add an {@link 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 {@link android.accessibilityservice.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
{@link android.accessibilityservice.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 {@link 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 {@link android.accessibilityservice.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
{@link #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:
Developer Guides
For more information about creating and processing AccessibilityEvents, read the
Accessibility
developer guide.
VIEW TYPES
View clicked - represents the event of clicking on a {@link android.view.View}
like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.
Type:{@link #TYPE_VIEW_CLICKED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #isPassword()} - Whether the source is password.
- {@link #isChecked()} - Whether the source is checked.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getItemCount()} - The total items of the source
(for descendants of AdapterView).
View long clicked - represents the event of long clicking on a {@link android.view.View}
like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc
Type:{@link #TYPE_VIEW_LONG_CLICKED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #isPassword()} - Whether the source is password.
- {@link #isChecked()} - Whether the source is checked.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #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 {@link android.widget.AdapterView}.
Type: {@link #TYPE_VIEW_SELECTED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #isPassword()} - Whether the source is password.
- {@link #isChecked()} - Whether the source is checked.
- {@link #getItemCount()} - The number of selectable items of the source.
- {@link #getCurrentItemIndex()} - The currently selected item index.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getItemCount()} - The total items of the source
(for descendants of AdapterView).
View focused - represents the event of focusing a
{@link android.view.View}.
Type: {@link #TYPE_VIEW_FOCUSED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #isPassword()} - Whether the source is password.
- {@link #isChecked()} - Whether the source is checked.
- {@link #getItemCount()} - The number of focusable items on the screen.
- {@link #getCurrentItemIndex()} - The currently focused item index.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getItemCount()} - The total items of the source
(for descendants of AdapterView).
View text changed - represents the event of changing the text of an
{@link android.widget.EditText}.
Type: {@link #TYPE_VIEW_TEXT_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #isPassword()} - Whether the source is password.
- {@link #isChecked()} - Whether the source is checked.
- {@link #getFromIndex()} - The text change start index.
- {@link #getAddedCount()} - The number of added characters.
- {@link #getRemovedCount()} - The number of removed characters.
- {@link #getBeforeText()} - The text of the source before the change.
- {@link #getContentDescription()} - The content description of the source.
View text selection changed - represents the event of changing the text
selection of an {@link android.widget.EditText}.
Type: {@link #TYPE_VIEW_TEXT_SELECTION_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source.
- {@link #isPassword()} - Whether the source is password.
- {@link #getFromIndex()} - The selection start index.
- {@link #getToIndex()} - The selection end index.
- {@link #getItemCount()} - The length of the source text.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #getContentDescription()} - The content description of the source.
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: {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getMovementGranularity()} - Sets the granularity at which a view's text
was traversed.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #getFromIndex()} - The start of the next/previous text at the specified granularity
- inclusive.
- {@link #getToIndex()} - The end of the next/previous text at the specified granularity
- exclusive.
- {@link #isPassword()} - Whether the source is password.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getMovementGranularity()} - Sets the granularity at which a view's text
was traversed.
- {@link #getAction()} - Gets traversal action which specifies the direction.
View scrolled - represents the event of scrolling a view. If
the source is a descendant of {@link android.widget.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: {@link #TYPE_VIEW_SCROLLED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getItemCount()} - The total items of the source
(for descendants of AdapterView).
Note: This event type is not dispatched to descendants though
{@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event
source {@link android.view.View} and the sub-tree rooted at it will not receive
calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent)
View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add
text content to such events is by setting the
{@link android.R.styleable#View_contentDescription contentDescription} of the source
view.
TRANSITION TYPES
Window state changed - represents the event of opening a
{@link android.widget.PopupWindow}, {@link android.view.Menu},
{@link android.app.Dialog}, etc.
Type: {@link #TYPE_WINDOW_STATE_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #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 {@link #TYPE_NOTIFICATION_STATE_CHANGED}
and its purpose is to notify clients that the content of the user interaction
window has changed.
Type: {@link #TYPE_WINDOW_CONTENT_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getContentChangeTypes()} - The type of content changes.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
Note: This event type is not dispatched to descendants though
{@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event
source {@link android.view.View} and the sub-tree rooted at it will not receive
calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent)
View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add
text content to such events is by setting the
{@link android.R.styleable#View_contentDescription contentDescription} of the source
view.
Windows changed - represents the event of changes in the windows shown on
the screen such as a window appeared, a window disappeared, a window size changed,
a window layer changed, etc.
Type: {@link #TYPE_WINDOWS_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getEventTime()} - The event time.
Note: You can retrieve the {@link AccessibilityWindowInfo} for the window
source of the event via {@link AccessibilityEvent#getSource()} to get the source
node on which then call {@link AccessibilityNodeInfo#getWindow()
AccessibilityNodeInfo.getWindow()} to get the window. Also all windows on the screen can
be retrieved by a call to {@link android.accessibilityservice.AccessibilityService#getWindows()
android.accessibilityservice.AccessibilityService.getWindows()}.
NOTIFICATION TYPES
Notification state changed - represents the event showing
{@link android.app.Notification}.
Type: {@link #TYPE_NOTIFICATION_STATE_CHANGED}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #getParcelableData()} - The posted {@link android.app.Notification}.
- {@link #getText()} - Text for providing more context.
Note: This event type is not dispatched to descendants though
{@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event
source {@link android.view.View} and the sub-tree rooted at it will not receive
calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent)
View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add
text content to such events is by setting the
{@link android.R.styleable#View_contentDescription contentDescription} of the source
view.
EXPLORATION TYPES
View hover enter - represents the event of beginning to hover
over a {@link android.view.View}. The hover may be generated via
exploring the screen by touch or via a pointing device.
Type: {@link #TYPE_VIEW_HOVER_ENTER}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getItemCount()} - The total items of the source
(for descendants of AdapterView).
View hover exit - represents the event of stopping to hover
over a {@link android.view.View}. The hover may be generated via
exploring the screen by touch or via a pointing device.
Type: {@link #TYPE_VIEW_HOVER_EXIT}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the source's sub-tree.
- {@link #isEnabled()} - Whether the source is enabled.
- {@link #getContentDescription()} - The content description of the source.
- {@link #getScrollX()} - The offset of the source left edge in pixels
(without descendants of AdapterView).
- {@link #getScrollY()} - The offset of the source top edge in pixels
(without descendants of AdapterView).
- {@link #getFromIndex()} - The zero based index of the first visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #getToIndex()} - The zero based index of the last visible item of the source,
inclusive (for descendants of AdapterView).
- {@link #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: {@link #TYPE_TOUCH_INTERACTION_START}
Properties:
- {@link #getEventType()} - The type of the event.
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: {@link #TYPE_TOUCH_INTERACTION_END}
Properties:
- {@link #getEventType()} - The type of the event.
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: {@link #TYPE_TOUCH_EXPLORATION_GESTURE_START}
Properties:
- {@link #getEventType()} - The type of the event.
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: {@link #TYPE_TOUCH_EXPLORATION_GESTURE_END}
Properties:
- {@link #getEventType()} - The type of the event.
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: {@link #TYPE_GESTURE_DETECTION_START}
Properties:
- {@link #getEventType()} - The type of the event.
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: {@link #TYPE_GESTURE_DETECTION_END}
Properties:
- {@link #getEventType()} - The type of the event.
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 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: {@link #TYPE_ANNOUNCEMENT}
Properties:
- {@link #getEventType()} - The type of the event.
- {@link #getSource()} - The source info (for registered clients).
- {@link #getClassName()} - The class name of the source.
- {@link #getPackageName()} - The package name of the source.
- {@link #getEventTime()} - The event time.
- {@link #getText()} - The text of the announcement.
- {@link #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.
|