Added in API level 14

AccessibilityRecord


open class AccessibilityRecord
kotlin.Any
   ↳ android.view.accessibility.AccessibilityRecord

Represents a record in an AccessibilityEvent and contains information about state change of its source android.view.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 android.accessibilityservice.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.

Summary

Public constructors

Creates a new AccessibilityRecord.

Copy constructor.

Public methods
open Int

Gets the number of added characters.

open CharSequence?

Gets the text before a change.

open CharSequence?

Gets the class name of the source.

open CharSequence?

Gets the description of the source.

open Int

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

open Int

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

open Int

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.

open Int

Gets the number of items that can be visited.

open Int

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

open Int

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

open Parcelable?

Gets the Parcelable data.

open Int

Gets the number of removed characters.

open Int

Gets the difference in pixels between the horizontal position before the scroll and the current horizontal position

open Int

Gets the difference in pixels between the vertical position before the scroll and the current vertical position

open Int

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

open Int

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

open AccessibilityNodeInfo?

Gets the AccessibilityNodeInfo of the event source.

open AccessibilityNodeInfo?
getSource(prefetchingStrategy: Int)

Gets the AccessibilityNodeInfo of the event source.

open MutableList<CharSequence!>

Gets the text of the event.

open Int

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

open Int

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

open Boolean

Gets if the source is checked.

open Boolean

Gets if the source is enabled.

open Boolean

Gets if the source is taking the entire screen.

open Boolean

Gets if the source is a password field.

open Boolean

Gets if the source is scrollable.

open static AccessibilityRecord

Instantiates a new record.

open static AccessibilityRecord

Instantiates a new record initialized with data from the given record.

open Unit

Would previously return an instance back to be reused.

open Unit
setAddedCount(addedCount: Int)

Sets the number of added characters.

open Unit

Sets the text before a change.

open Unit
setChecked(isChecked: Boolean)

Sets if the source is checked.

open Unit

Sets the class name of the source.

open Unit
setContentDescription(contentDescription: CharSequence?)

Sets the description of the source.

open Unit
setCurrentItemIndex(currentItemIndex: Int)

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

open Unit
setEnabled(isEnabled: Boolean)

Sets if the source is enabled.

open Unit
setFromIndex(fromIndex: Int)

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.

open Unit
setFullScreen(isFullScreen: Boolean)

Sets if the source is taking the entire screen.

open Unit
setItemCount(itemCount: Int)

Sets the number of items that can be visited.

open Unit
setMaxScrollX(maxScrollX: Int)

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

open Unit
setMaxScrollY(maxScrollY: Int)

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

open Unit
setParcelableData(parcelableData: Parcelable?)

Sets the Parcelable data of the event.

open Unit
setPassword(isPassword: Boolean)

Sets if the source is a password field.

open Unit
setRemovedCount(removedCount: Int)

Sets the number of removed characters.

open Unit
setScrollDeltaX(scrollDeltaX: Int)

Sets the difference in pixels between the horizontal position before the scroll and the current horizontal position

open Unit
setScrollDeltaY(scrollDeltaY: Int)

Sets the difference in pixels between the vertical position before the scroll and the current vertical position

open Unit
setScrollX(scrollX: Int)

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

open Unit
setScrollY(scrollY: Int)

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

open Unit
setScrollable(scrollable: Boolean)

Sets if the source is scrollable.

open Unit
setSource(source: View?)

Sets the event source.

open Unit
setSource(root: View?, virtualDescendantId: Int)

Sets the source to be a virtual descendant of the given root.

open Unit
setToIndex(toIndex: Int)

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

open String

Public constructors

AccessibilityRecord

Added in API level 30
AccessibilityRecord()

Creates a new AccessibilityRecord.

AccessibilityRecord

Added in API level 30
AccessibilityRecord(record: AccessibilityRecord)

Copy constructor. Creates a new AccessibilityRecord, and this instance is initialized with data from the given record.

Parameters
record AccessibilityRecord: The other record. This value cannot be null.

Public methods

getAddedCount

Added in API level 14
open fun getAddedCount(): Int

Gets the number of added characters.

Return
Int The number of added characters.

getBeforeText

Added in API level 14
open fun getBeforeText(): CharSequence?

Gets the text before a change.

Return
CharSequence? The text before the change. This value may be null.

getClassName

Added in API level 14
open fun getClassName(): CharSequence?

Gets the class name of the source.

Return
CharSequence? The class name. This value may be null.

getContentDescription

Added in API level 14
open fun getContentDescription(): CharSequence?

Gets the description of the source.

Return
CharSequence? The description. This value may be null.

getCurrentItemIndex

Added in API level 14
open fun getCurrentItemIndex(): Int

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

Return
Int The current item index.

getDisplayId

Added in API level 33
open fun getDisplayId(): Int

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

Return
Int The display id.

getFromIndex

Added in API level 14
open fun getFromIndex(): Int

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.

Return
Int The index of the first character or selection start or the first visible item.

getItemCount

Added in API level 14
open fun getItemCount(): Int

Gets the number of items that can be visited.

Return
Int The number of items.

getMaxScrollX

Added in API level 15
open fun getMaxScrollX(): Int

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

Return
Int The max scroll.

getMaxScrollY

Added in API level 15
open fun getMaxScrollY(): Int

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

Return
Int The max scroll.

getParcelableData

Added in API level 14
open fun getParcelableData(): Parcelable?

Gets the Parcelable data.

Return
Parcelable? The parcelable data. This value may be null.

getRemovedCount

Added in API level 14
open fun getRemovedCount(): Int

Gets the number of removed characters.

Return
Int The number of removed characters.

getScrollDeltaX

Added in API level 28
open fun getScrollDeltaX(): Int

Gets the difference in pixels between the horizontal position before the scroll and the current horizontal position

Return
Int the scroll delta x

getScrollDeltaY

Added in API level 28
open fun getScrollDeltaY(): Int

Gets the difference in pixels between the vertical position before the scroll and the current vertical position

Return
Int the scroll delta y

getScrollX

Added in API level 14
open fun getScrollX(): Int

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

Return
Int The scroll.

getScrollY

Added in API level 14
open fun getScrollY(): Int

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

Return
Int The scroll.

getSource

Added in API level 14
open fun getSource(): AccessibilityNodeInfo?

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.

Return
AccessibilityNodeInfo? The info of the source. This value may be null.

getText

Added in API level 14
open fun getText(): MutableList<CharSequence!>

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.

Return
MutableList<CharSequence!> The text. This value cannot be null.

getToIndex

Added in API level 14
open fun getToIndex(): Int

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

Return
Int The index of selection end or last item index.

getWindowId

Added in API level 14
open fun getWindowId(): Int

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

Return
Int The window id.

isChecked

Added in API level 14
open fun isChecked(): Boolean

Gets if the source is checked.

Return
Boolean True if the view is checked, false otherwise.

isEnabled

Added in API level 14
open fun isEnabled(): Boolean

Gets if the source is enabled.

Return
Boolean True if the view is enabled, false otherwise.

isFullScreen

Added in API level 14
open fun isFullScreen(): Boolean

Gets if the source is taking the entire screen.

Return
Boolean True if the source is full screen, false otherwise.

isPassword

Added in API level 14
open fun isPassword(): Boolean

Gets if the source is a password field.

Return
Boolean True if the view is a password field, false otherwise.

isScrollable

Added in API level 14
open fun isScrollable(): Boolean

Gets if the source is scrollable.

Return
Boolean True if the source is scrollable, false otherwise.

obtain

Added in API level 14
Deprecated in API level 33
open static fun obtain(): AccessibilityRecord

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

Instantiates a new record.

Return
AccessibilityRecord An instance. This value cannot be null.

obtain

Added in API level 14
Deprecated in API level 33
open static fun obtain(record: AccessibilityRecord): AccessibilityRecord

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

Instantiates a new record initialized with data from the given record.

Parameters
record AccessibilityRecord: This value cannot be null.
Return
AccessibilityRecord An instance. This value cannot be null.

recycle

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

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

Would previously return an instance back to be reused.

setAddedCount

Added in API level 14
open fun setAddedCount(addedCount: Int): Unit

Sets the number of added characters.

Parameters
addedCount Int: The number of added characters.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setBeforeText

Added in API level 14
open fun setBeforeText(beforeText: CharSequence?): Unit

Sets the text before a change.

Parameters
beforeText CharSequence?: The text before the change. This value may be null.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setChecked

Added in API level 14
open fun setChecked(isChecked: Boolean): Unit

Sets if the source is checked.

Parameters
isChecked Boolean: True if the view is checked, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setClassName

Added in API level 14
open fun setClassName(className: CharSequence?): Unit

Sets the class name of the source.

Parameters
className CharSequence?: The lass name. This value may be null.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setContentDescription

Added in API level 14
open fun setContentDescription(contentDescription: CharSequence?): Unit

Sets the description of the source.

Parameters
contentDescription CharSequence?: The description. This value may be null.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setCurrentItemIndex

Added in API level 14
open fun setCurrentItemIndex(currentItemIndex: Int): Unit

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

Parameters
currentItemIndex Int: The current item index.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setEnabled

Added in API level 14
open fun setEnabled(isEnabled: Boolean): Unit

Sets if the source is enabled.

Parameters
isEnabled Boolean: True if the view is enabled, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setFromIndex

Added in API level 14
open fun setFromIndex(fromIndex: Int): Unit

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 Int: The index of the first character or selection start or the first visible item.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setFullScreen

Added in API level 14
open fun setFullScreen(isFullScreen: Boolean): Unit

Sets if the source is taking the entire screen.

Parameters
isFullScreen Boolean: True if the source is full screen, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setItemCount

Added in API level 14
open fun setItemCount(itemCount: Int): Unit

Sets the number of items that can be visited.

Parameters
itemCount Int: The number of items.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setMaxScrollX

Added in API level 15
open fun setMaxScrollX(maxScrollX: Int): Unit

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

Parameters
maxScrollX Int: The max scroll.

setMaxScrollY

Added in API level 15
open fun setMaxScrollY(maxScrollY: Int): Unit

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

Parameters
maxScrollY Int: The max scroll.

setParcelableData

Added in API level 14
open fun setParcelableData(parcelableData: Parcelable?): Unit

Sets the Parcelable data of the event.

Parameters
parcelableData Parcelable?: The parcelable data. This value may be null.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setPassword

Added in API level 14
open fun setPassword(isPassword: Boolean): Unit

Sets if the source is a password field.

Parameters
isPassword Boolean: True if the view is a password field, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setRemovedCount

Added in API level 14
open fun setRemovedCount(removedCount: Int): Unit

Sets the number of removed characters.

Parameters
removedCount Int: The number of removed characters.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setScrollDeltaX

Added in API level 28
open fun setScrollDeltaX(scrollDeltaX: Int): Unit

Sets the difference in pixels between the horizontal position before the scroll and the current horizontal position

Parameters
scrollDeltaX Int: the scroll delta x

setScrollDeltaY

Added in API level 28
open fun setScrollDeltaY(scrollDeltaY: Int): Unit

Sets the difference in pixels between the vertical position before the scroll and the current vertical position

Parameters
scrollDeltaY Int: the scroll delta y

setScrollX

Added in API level 14
open fun setScrollX(scrollX: Int): Unit

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

Parameters
scrollX Int: The scroll.

setScrollY

Added in API level 14
open fun setScrollY(scrollY: Int): Unit

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

Parameters
scrollY Int: The scroll.

setScrollable

Added in API level 14
open fun setScrollable(scrollable: Boolean): Unit

Sets if the source is scrollable.

Parameters
scrollable Boolean: True if the source is scrollable, false otherwise.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setSource

Added in API level 14
open fun setSource(source: View?): Unit

Sets the event source.

Parameters
source View?: The source. This value may be null.
Exceptions
java.lang.IllegalStateException If called from an AccessibilityService.

setSource

Added in API level 16
open fun setSource(
    root: View?,
    virtualDescendantId: Int
): Unit

Sets the source to be a virtual descendant of the given root. If virtualDescendantId equals to View.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 View?: The root of the virtual subtree. This value may be null.
virtualDescendantId Int: The id of the virtual descendant.

setToIndex

Added in API level 14
open fun setToIndex(toIndex: Int): Unit

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

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

toString

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