AccessibilityRequestPreparer


public abstract class AccessibilityRequestPreparer
extends Object

java.lang.Object
   ↳ android.view.accessibility.AccessibilityRequestPreparer


Object responsible to ensuring that a View is prepared to meet a synchronous request for accessibility data.

Because accessibility requests arrive to Views synchronously on the UI thread, a View that requires information from other processes can struggle to meet those requests. Registering an instance of this class with AccessibilityManager allows a View to be notified when a request is about to be made, and to asynchronously inform the accessibility system when it is ready to meet the request.

Note: This class should only be needed in exceptional situations where a View cannot otherwise synchronously meet the request for accessibility data.

Summary

Constants

int REQUEST_TYPE_EXTRA_DATA

Public constructors

AccessibilityRequestPreparer(View view, int requestTypes)

Public methods

View getView()

Get the view this object was created with.

abstract void onPrepareExtraData(int virtualViewId, String extraDataKey, Bundle args, Message preparationFinishedMessage)

Callback to allow preparation for filling extra data.

Inherited methods

Constants

REQUEST_TYPE_EXTRA_DATA

Added in API level 27
public static final int REQUEST_TYPE_EXTRA_DATA

Constant Value: 1 (0x00000001)

Public constructors

AccessibilityRequestPreparer

Added in API level 27
public AccessibilityRequestPreparer (View view, 
                int requestTypes)

Parameters
view View: The view whose requests need preparation. It must be attached to a window. This object will retain a weak reference to this view, and will unregister itself from AccessibilityManager if the view is detached from a window. It will not re-register itself.

requestTypes int: The types of requests that require preparation. Different types may be ORed together. Value is either 0 or REQUEST_TYPE_EXTRA_DATA

Throws
IllegalStateException if the view is not attached to a window.

Public methods

getView

Added in API level 27
public View getView ()

Get the view this object was created with.

Returns
View The view this object was created with, or null if the weak reference held to the view is no longer valid.

onPrepareExtraData

Added in API level 27
public abstract void onPrepareExtraData (int virtualViewId, 
                String extraDataKey, 
                Bundle args, 
                Message preparationFinishedMessage)

Callback to allow preparation for filling extra data. Only called back if REQUEST_TYPE_EXTRA_DATA is requested.

Parameters
virtualViewId int: The ID of a virtual child node, if the View for this preparer supports virtual descendents, or AccessibilityNodeProvider#HOST_VIEW_ID if the request is for the view itself.

extraDataKey String: The extra data key for the request

args Bundle: The arguments for the request

preparationFinishedMessage Message: A message that must be sent to its target when preparations are complete.