to top
Android APIs
public class

AccessibilityRecord

extends Object
java.lang.Object
   ↳ android.view.accessibility.AccessibilityRecord
Known Direct Subclasses

Class Overview

Represents a record in an AccessibilityEvent and contains information about state change of its source View. When a view fires an accessibility event it requests from its parent to dispatch the constructed event. The parent may optionally append a record for itself for providing more context to AccessibilityServices. Hence, accessibility services can facilitate additional accessibility records to enhance feedback.

Once the accessibility event containing a record is dispatched the record is made immutable and calling a state mutation method generates an error.

Note: Not all properties are applicable to all accessibility event types. For detailed information please refer to AccessibilityEvent.

Developer Guides

For more information about creating and processing AccessibilityRecords, read the Accessibility developer guide.

Summary

Public Methods

? Examples
int getAddedCount()
Gets the number of added characters.

? Examples
CharSequence getBeforeText()
Sets the text before a change.

? Examples
CharSequence getClassName()
Gets the class name of the source.

? Examples
CharSequence getContentDescription()
Gets the description of the source.

? Examples
int getCurrentItemIndex()
Gets the index of the source in the list of items the can be visited.

? Examples
int getFromIndex()
Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling.

? Examples
int getItemCount()
Gets the number of items that can be visited.

? Examples
int getMaxScrollX()
Gets the max scroll offset of the source left edge in pixels.

? Examples
int getMaxScrollY()
Gets the max scroll offset of the source top edge in pixels.

? Examples
Parcelable getParcelableData()
Gets the Parcelable data.

? Examples
int getRemovedCount()
Gets the number of removed characters.

? Examples
int getScrollX()
Gets the scroll offset of the source left edge in pixels.

? Examples
int getScrollY()
Gets the scroll offset of the source top edge in pixels.

? Examples
AccessibilityNodeInfo getSource()
Gets the AccessibilityNodeInfo of the event source.

? Examples
List< CharSequence> getText()
Gets the text of the event.

? Examples
int getToIndex()
Gets the index of text selection end or the index of the last visible item when scrolling.

? Examples
int getWindowId()
Gets the id of the window from which the event comes from.

? Examples
boolean isChecked()
Gets if the source is checked.

? Examples
boolean isEnabled()
Gets if the source is enabled.

? Examples
boolean isFullScreen()
Gets if the source is taking the entire screen.

? Examples
boolean isPassword()
Gets if the source is a password field.

? Examples
boolean isScrollable()
Gets if the source is scrollable.

? Examples
static AccessibilityRecord obtain( AccessibilityRecord record)
Returns a cached instance if such is available or a new one is instantiated.

? Examples
static AccessibilityRecord obtain()
Returns a cached instance if such is available or a new one is instantiated.

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

? Examples
void setAddedCount(int addedCount)
Sets the number of added characters.

? Examples
void setBeforeText( CharSequence beforeText)
Sets the text before a change.

? Examples
void setChecked(boolean isChecked)
Sets if the source is checked.

? Examples
void setClassName( CharSequence className)
Sets the class name of the source.

? Examples
void setContentDescription( CharSequence contentDescription)
Sets the description of the source.

? Examples
void setCurrentItemIndex(int currentItemIndex)
Sets the index of the source in the list of items that can be visited.

? Examples
void setEnabled(boolean isEnabled)
Sets if the source is enabled.

? Examples
void setFromIndex(int fromIndex)
Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.

? Examples
void setFullScreen(boolean isFullScreen)
Sets if the source is taking the entire screen.

? Examples
void setItemCount(int itemCount)
Sets the number of items that can be visited.

? Examples
void setMaxScrollX(int maxScrollX)
Sets the max scroll offset of the source left edge in pixels.

? Examples
void setMaxScrollY(int maxScrollY)
Sets the max scroll offset of the source top edge in pixels.

? Examples
void setParcelableData( Parcelable parcelableData)
Sets the Parcelable data of the event.

? Examples
void setPassword(boolean isPassword)
Sets if the source is a password field.

? Examples
void setRemovedCount(int removedCount)
Sets the number of removed characters.

? Examples
void setScrollX(int scrollX)
Sets the scroll offset of the source left edge in pixels.

? Examples
void setScrollY(int scrollY)
Sets the scroll offset of the source top edge in pixels.

? Examples
void setScrollable(boolean scrollable)
Sets if the source is scrollable.

? Examples
void setSource( View root, int virtualDescendantId)
Sets the source to be a virtual descendant of the given root.

? Examples
void setSource( View source)
Sets the event source.

? Examples
void setToIndex(int toIndex)
Sets the index of text selection end or the index of the last visible item when scrolling.

? Examples
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public int getAddedCount ()

Added in API level 4

Gets the number of added characters.

Returns
  • The number of added characters.

public CharSequence getBeforeText ()

Added in API level 4

Sets the text before a change.

Returns
  • The text before the change.

public CharSequence getClassName ()

Added in API level 4

Gets the class name of the source.

Returns
  • The class name.

public CharSequence getContentDescription ()

Added in API level 4

Gets the description of the source.

Returns
  • The description.

public int getCurrentItemIndex ()

Added in API level 4

Gets the index of the source in the list of items the can be visited.

Returns
  • The current item index.

public int getFromIndex ()

Added in API level 4

Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling.

Returns
  • The index of the first character or selection start or the first visible item.

public int getItemCount ()

Added in API level 4

Gets the number of items that can be visited.

Returns
  • The number of items.

public int getMaxScrollX ()

Added in API level 15

Gets the max scroll offset of the source left edge in pixels.

Returns
  • The max scroll.

public int getMaxScrollY ()

Added in API level 15

Gets the max scroll offset of the source top edge in pixels.

Returns
  • The max scroll.

public Parcelable getParcelableData ()

Added in API level 4

Gets the Parcelable data.

Returns
  • The parcelable data.

public int getRemovedCount ()

Added in API level 4

Gets the number of removed characters.

Returns
  • The number of removed characters.

public int getScrollX ()

Added in API level 14

Gets the scroll offset of the source left edge in pixels.

Returns
  • The scroll.

public int getScrollY ()

Added in API level 14

Gets the scroll offset of the source top edge in pixels.

Returns
  • The scroll.

public AccessibilityNodeInfo getSource ()

Added in API level 14

Gets the AccessibilityNodeInfo of the event source.

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

Returns
  • The info of the source.

public List<CharSequence> getText ()

Added in API level 4

Gets the text of the event. The index in the list represents the priority of the text. Specifically, the lower the index the higher the priority.

Returns
  • The text.

public int getToIndex ()

Added in API level 14

Gets the index of text selection end or the index of the last visible item when scrolling.

Returns
  • The index of selection end or last item index.

public int getWindowId ()

Added in API level 14

Gets the id of the window from which the event comes from.

Returns
  • The window id.

public boolean isChecked ()

Added in API level 4

Gets if the source is checked.

Returns
  • True if the view is checked, false otherwise.

public boolean isEnabled ()

Added in API level 4

Gets if the source is enabled.

Returns
  • True if the view is enabled, false otherwise.

public boolean isFullScreen ()

Added in API level 4

Gets if the source is taking the entire screen.

Returns
  • True if the source is full screen, false otherwise.

public boolean isPassword ()

Added in API level 4

Gets if the source is a password field.

Returns
  • True if the view is a password field, false otherwise.

public boolean isScrollable ()

Added in API level 14

Gets if the source is scrollable.

Returns
  • True if the source is scrollable, false otherwise.

public static AccessibilityRecord obtain (AccessibilityRecord record)

Added in API level 14

Returns a cached instance if such is available or a new one is instantiated. The instance is initialized with data from the given record.

Returns
  • An instance.

public static AccessibilityRecord obtain ()

Added in API level 14

Returns a cached instance if such is available or a new one is instantiated.

Returns
  • An instance.

public void recycle ()

Added in API level 14

Return an instance back to be reused.

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

Throws
IllegalStateException If the record is already recycled.

public void setAddedCount (int addedCount)

Added in API level 4

Sets the number of added characters.

Parameters
addedCount The number of added characters.
Throws
IllegalStateException If called from an AccessibilityService.

public void setBeforeText (CharSequence beforeText)

Added in API level 4

Sets the text before a change.

Parameters
beforeText The text before the change.
Throws
IllegalStateException If called from an AccessibilityService.

public void setChecked (boolean isChecked)

Added in API level 4

Sets if the source is checked.

Parameters
isChecked True if the view is checked, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setClassName (CharSequence className)

Added in API level 4

Sets the class name of the source.

Parameters
className The lass name.
Throws
IllegalStateException If called from an AccessibilityService.

public void setContentDescription (CharSequence contentDescription)

Added in API level 4

Sets the description of the source.

Parameters
contentDescription The description.
Throws
IllegalStateException If called from an AccessibilityService.

public void setCurrentItemIndex (int currentItemIndex)

Added in API level 4

Sets the index of the source in the list of items that can be visited.

Parameters
currentItemIndex The current item index.
Throws
IllegalStateException If called from an AccessibilityService.

public void setEnabled (boolean isEnabled)

Added in API level 4

Sets if the source is enabled.

Parameters
isEnabled True if the view is enabled, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setFromIndex (int fromIndex)

Added in API level 4

Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.

Parameters
fromIndex The index of the first character or selection start or the first visible item.
Throws
IllegalStateException If called from an AccessibilityService.

public void setFullScreen (boolean isFullScreen)

Added in API level 4

Sets if the source is taking the entire screen.

Parameters
isFullScreen True if the source is full screen, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setItemCount (int itemCount)

Added in API level 4

Sets the number of items that can be visited.

Parameters
itemCount The number of items.
Throws
IllegalStateException If called from an AccessibilityService.

public void setMaxScrollX (int maxScrollX)

Added in API level 15

Sets the max scroll offset of the source left edge in pixels.

Parameters
maxScrollX The max scroll.

public void setMaxScrollY (int maxScrollY)

Added in API level 15

Sets the max scroll offset of the source top edge in pixels.

Parameters
maxScrollY The max scroll.

public void setParcelableData (Parcelable parcelableData)

Added in API level 4

Sets the Parcelable data of the event.

Parameters
parcelableData The parcelable data.
Throws
IllegalStateException If called from an AccessibilityService.

public void setPassword (boolean isPassword)

Added in API level 4

Sets if the source is a password field.

Parameters
isPassword True if the view is a password field, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setRemovedCount (int removedCount)

Added in API level 4

Sets the number of removed characters.

Parameters
removedCount The number of removed characters.
Throws
IllegalStateException If called from an AccessibilityService.

public void setScrollX (int scrollX)

Added in API level 14

Sets the scroll offset of the source left edge in pixels.

Parameters
scrollX The scroll.

public void setScrollY (int scrollY)

Added in API level 14

Sets the scroll offset of the source top edge in pixels.

Parameters
scrollY The scroll.

public void setScrollable (boolean scrollable)

Added in API level 14

Sets if the source is scrollable.

Parameters
scrollable True if the source is scrollable, false otherwise.
Throws
IllegalStateException If called from an AccessibilityService.

public void setSource (View root, int virtualDescendantId)

Added in API level 16

Sets the source to be a virtual descendant of the given root. If virtualDescendantId equals to NO_ID the root is set as the source.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

Parameters
root The root of the virtual subtree.
virtualDescendantId The id of the virtual descendant.

public void setSource (View source)

Added in API level 14

Sets the event source.

Parameters
source The source.
Throws
IllegalStateException If called from an AccessibilityService.

public void setToIndex (int toIndex)

Added in API level 14

Sets the index of text selection end or the index of the last visible item when scrolling.

Parameters
toIndex The index of selection end or last item index.

public String toString ()

Added in API level 14

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.

Returns
  • a printable representation of this object.
No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.