AccessibilityManager
  public
  
  final
  
  class
  AccessibilityManager
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.view.accessibility.AccessibilityManager | 
System level service that serves as an event dispatch for AccessibilityEvents,
 and provides facilities for querying the accessibility state of the system.
 Accessibility events are generated when something notable happens in the user interface,
 for example an Activity starts, the focus or selection of a
 View changes etc. Parties interested in handling accessibility
 events implement and register an accessibility service which extends
 AccessibilityService.
See also:
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        interface | AccessibilityManager.AccessibilityServicesStateChangeListenerListener for changes to the state of accessibility services. | 
| 
        
        
        
        
        interface | AccessibilityManager.AccessibilityStateChangeListenerListener for the system accessibility state. | 
| 
        
        
        
        
        interface | AccessibilityManager.AudioDescriptionRequestedChangeListenerListener for the audio description by default state. | 
| 
        
        
        
        
        interface | AccessibilityManager.HighContrastTextStateChangeListenerListener for the system high contrast text state. | 
| 
        
        
        
        
        interface | AccessibilityManager.TouchExplorationStateChangeListenerListener for the system touch exploration state. | 
| Constants | |
|---|---|
| int | FLAG_CONTENT_CONTROLSUse this flag to indicate the content of a UI that times out contains interactive controls. | 
| int | FLAG_CONTENT_ICONSUse this flag to indicate the content of a UI that times out contains icons. | 
| int | FLAG_CONTENT_TEXTUse this flag to indicate the content of a UI that times out contains text. | 
| Inherited methods | |
|---|---|
Constants
FLAG_CONTENT_CONTROLS
public static final int FLAG_CONTENT_CONTROLS
Use this flag to indicate the content of a UI that times out contains interactive controls.
See also:
Constant Value: 4 (0x00000004)
FLAG_CONTENT_ICONS
public static final int FLAG_CONTENT_ICONS
Use this flag to indicate the content of a UI that times out contains icons.
See also:
Constant Value: 1 (0x00000001)
FLAG_CONTENT_TEXT
public static final int FLAG_CONTENT_TEXT
Use this flag to indicate the content of a UI that times out contains text.
See also:
Constant Value: 2 (0x00000002)
Public methods
addAccessibilityRequestPreparer
public void addAccessibilityRequestPreparer (AccessibilityRequestPreparer preparer)
Registers a AccessibilityRequestPreparer.
| Parameters | |
|---|---|
| preparer | AccessibilityRequestPreparer | 
addAccessibilityServicesStateChangeListener
public void addAccessibilityServicesStateChangeListener (Executor executor, AccessibilityManager.AccessibilityServicesStateChangeListener listener)
Registers a AccessibilityServicesStateChangeListener.
| Parameters | |
|---|---|
| executor | Executor: The executor.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| listener | AccessibilityManager.AccessibilityServicesStateChangeListener: The listener.
 This value cannot benull. | 
addAccessibilityServicesStateChangeListener
public void addAccessibilityServicesStateChangeListener (AccessibilityManager.AccessibilityServicesStateChangeListener listener)
Registers a AccessibilityServicesStateChangeListener. This will execute a callback on
 the process's main handler.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AccessibilityServicesStateChangeListener: The listener.
 This value cannot benull. | 
addAccessibilityStateChangeListener
public boolean addAccessibilityStateChangeListener (AccessibilityManager.AccessibilityStateChangeListener listener)
Registers an AccessibilityStateChangeListener for changes in
 the global accessibility state of the system. Equivalent to calling
 addAccessibilityStateChangeListener(android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener, android.os.Handler)
 with a null handler.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AccessibilityStateChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | Always returns true. | 
addAccessibilityStateChangeListener
public void addAccessibilityStateChangeListener (AccessibilityManager.AccessibilityStateChangeListener listener, Handler handler)
Registers an AccessibilityStateChangeListener for changes in
 the global accessibility state of the system. If the listener has already been registered,
 the handler used to call it back is updated.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AccessibilityStateChangeListener: The listener.
 This value cannot benull. | 
| handler | Handler: The handler on which the listener should be called back, ornullfor a callback on the process's main handler. | 
addAudioDescriptionRequestedChangeListener
public void addAudioDescriptionRequestedChangeListener (Executor executor, AccessibilityManager.AudioDescriptionRequestedChangeListener listener)
Registers a AudioDescriptionRequestedChangeListener
 for changes in the audio description by default state of the system.
 The value could be read via isAudioDescriptionRequested().
| Parameters | |
|---|---|
| executor | Executor: The executor on which the listener should be called back.
 This value cannot benull. | 
| listener | AccessibilityManager.AudioDescriptionRequestedChangeListener: The listener.
 This value cannot benull. | 
addHighContrastTextStateChangeListener
public void addHighContrastTextStateChangeListener (Executor executor, AccessibilityManager.HighContrastTextStateChangeListener listener)
Registers a HighContrastTextStateChangeListener for changes in
 the global high contrast text state of the system.
| Parameters | |
|---|---|
| executor | Executor: a executor to call the listener from
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| listener | AccessibilityManager.HighContrastTextStateChangeListener: The listener to be called
 This value cannot benull. | 
addTouchExplorationStateChangeListener
public boolean addTouchExplorationStateChangeListener (AccessibilityManager.TouchExplorationStateChangeListener listener)
Registers a TouchExplorationStateChangeListener for changes in
 the global touch exploration state of the system. Equivalent to calling
 addTouchExplorationStateChangeListener(android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener, android.os.Handler)
 with a null handler.
| Parameters | |
|---|---|
| listener | AccessibilityManager.TouchExplorationStateChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | Always returns true. | 
addTouchExplorationStateChangeListener
public void addTouchExplorationStateChangeListener (AccessibilityManager.TouchExplorationStateChangeListener listener, Handler handler)
Registers an TouchExplorationStateChangeListener for changes in
 the global touch exploration state of the system. If the listener has already been
 registered, the handler used to call it back is updated.
| Parameters | |
|---|---|
| listener | AccessibilityManager.TouchExplorationStateChangeListener: The listener.
 This value cannot benull. | 
| handler | Handler: The handler on which the listener should be called back, ornullfor a callback on the process's main handler. | 
getAccessibilityFocusColor
public int getAccessibilityFocusColor ()
Gets the color of the focus rectangle. This value can be set by
 AccessibilityService.
| Returns | |
|---|---|
| int | The color of the focus rectangle. | 
getAccessibilityFocusStrokeWidth
public int getAccessibilityFocusStrokeWidth ()
Gets the strokeWidth of the focus rectangle. This value can be set by
 AccessibilityService.
| Returns | |
|---|---|
| int | The strokeWidth of the focus rectangle in pixels. | 
getAccessibilityServiceList
public List<ServiceInfo> getAccessibilityServiceList ()
      This method was deprecated
      in API level 15.
    Use getInstalledAccessibilityServiceList()
  
Returns the ServiceInfos of the installed accessibility services.
| Returns | |
|---|---|
| List<ServiceInfo> | An unmodifiable list with ServiceInfos. | 
getEnabledAccessibilityServiceList
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList (int feedbackTypeFlags)
Returns the AccessibilityServiceInfos of the enabled accessibility services
 for a given feedback type.
| Parameters | |
|---|---|
| feedbackTypeFlags | int: The feedback type flags. | 
| Returns | |
|---|---|
| List<AccessibilityServiceInfo> | An unmodifiable list with AccessibilityServiceInfos. | 
getInstalledAccessibilityServiceList
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList ()
Returns the AccessibilityServiceInfos of the installed accessibility services.
| Returns | |
|---|---|
| List<AccessibilityServiceInfo> | An unmodifiable list with AccessibilityServiceInfos. | 
getRecommendedTimeoutMillis
public int getRecommendedTimeoutMillis (int originalTimeout, 
                int uiContentFlags)Get the recommended timeout for changes to the UI needed by this user. Controls should remain on the screen for at least this long to give users time to react. Some users may need extra time to review the controls, or to reach them, or to activate assistive technology to activate the controls automatically.
 Use the combination of content flags to indicate contents of UI. For example, use
 FLAG_CONTENT_ICONS | FLAG_CONTENT_TEXT for message notification which contains
 icons and text, or use FLAG_CONTENT_TEXT | FLAG_CONTENT_CONTROLS for button dialog
 which contains text and button controls.
 
| Parameters | |
|---|---|
| originalTimeout | int: The timeout appropriate for users with no accessibility needs. | 
| uiContentFlags | int: The combination of flagsFLAG_CONTENT_ICONS,FLAG_CONTENT_TEXTorFLAG_CONTENT_CONTROLSto
                       indicate the contents of UI.
 Value is either0or a combination ofFLAG_CONTENT_ICONS,FLAG_CONTENT_TEXT, andFLAG_CONTENT_CONTROLS | 
| Returns | |
|---|---|
| int | The recommended UI timeout for the current user in milliseconds. | 
interrupt
public void interrupt ()
Requests feedback interruption from all accessibility services.
isAccessibilityButtonSupported
public static boolean isAccessibilityButtonSupported ()
Determines if the accessibility button within the system navigation area is supported.
| Returns | |
|---|---|
| boolean | trueif the accessibility button is supported on this device,falseotherwise | 
isAudioDescriptionRequested
public boolean isAudioDescriptionRequested ()
Determines if users want to select sound track with audio description by default.
Audio description, also referred to as a video description, described video, or more precisely called a visual description, is a form of narration used to provide information surrounding key visual elements in a media work for the benefit of blind and visually impaired consumers.
The method provides the preference value to content provider apps to select the default sound track during playing a video or movie.
 Add listener to detect the state change via
 addAudioDescriptionRequestedChangeListener(Executor, AudioDescriptionRequestedChangeListener)
 
| Returns | |
|---|---|
| boolean | trueif the audio description is enabled,falseotherwise. | 
isEnabled
public boolean isEnabled ()
Returns if the accessibility in the system is enabled.
 Note: This query is used for sending AccessibilityEvents, since events are
 only needed if accessibility is on. Avoid changing UI or app behavior based on the state of
 accessibility. While well-intentioned, doing this creates brittle, less
 well-maintained code that works for some users but not others. Shared code leads to more
 equitable experiences and less technical debt.
For example, if you want to expose a unique interaction with your app, use ViewCompat#addAccessibilityAction in AndroidX to make this interaction - ideally with the same code path used for non-accessibility users - available to accessibility services. Services can then expose this action in the way best fit for their users.
| Returns | |
|---|---|
| boolean | True if accessibility is enabled, false otherwise. | 
isHighContrastTextEnabled
public boolean isHighContrastTextEnabled ()
Returns if high contrast text in the system is enabled.
Note: You need to query this only if you application is doing its own rendering and does not rely on the platform rendering pipeline.
| Returns | |
|---|---|
| boolean | True if high contrast text is enabled, false otherwise. | 
isRequestFromAccessibilityTool
public boolean isRequestFromAccessibilityTool ()
Whether the current accessibility request comes from an
 AccessibilityService with the AccessibilityServiceInfo.isAccessibilityTool
 property set to true.
 
 You can use this method inside AccessibilityNodeProvider to decide how to populate
 your nodes.
 
 Note: The return value is valid only when an AccessibilityNodeInfo
 request is in progress, can change from one request to another, and has no meaning when a
 request is not in progress.
 
| Returns | |
|---|---|
| boolean | True if the current request is from a tool that sets isAccessibilityTool. | 
isTouchExplorationEnabled
public boolean isTouchExplorationEnabled ()
Returns if the touch exploration in the system is enabled.
 Note: This query is used for dispatching hover events, such as
 MotionEvent.ACTION_HOVER_ENTER, to accessibility services to manage
 touch exploration. Avoid changing UI or app behavior based on the state of accessibility.
 While well-intentioned, doing this creates brittle, less well-maintained code that works for
 som users but not others. Shared code leads to more equitable experiences and less technical
 debt.
| Returns | |
|---|---|
| boolean | True if touch exploration is enabled, false otherwise. | 
removeAccessibilityRequestPreparer
public void removeAccessibilityRequestPreparer (AccessibilityRequestPreparer preparer)
Unregisters a AccessibilityRequestPreparer.
| Parameters | |
|---|---|
| preparer | AccessibilityRequestPreparer | 
removeAccessibilityServicesStateChangeListener
public boolean removeAccessibilityServicesStateChangeListener (AccessibilityManager.AccessibilityServicesStateChangeListener listener)
Unregisters a AccessibilityServicesStateChangeListener.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AccessibilityServicesStateChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | trueif the listener was previously registered. | 
removeAccessibilityStateChangeListener
public boolean removeAccessibilityStateChangeListener (AccessibilityManager.AccessibilityStateChangeListener listener)
Unregisters an AccessibilityStateChangeListener.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AccessibilityStateChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | True if the listener was previously registered. | 
removeAudioDescriptionRequestedChangeListener
public boolean removeAudioDescriptionRequestedChangeListener (AccessibilityManager.AudioDescriptionRequestedChangeListener listener)
Unregisters a AudioDescriptionRequestedChangeListener.
| Parameters | |
|---|---|
| listener | AccessibilityManager.AudioDescriptionRequestedChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | True if listener was previously registered. | 
removeHighContrastTextStateChangeListener
public void removeHighContrastTextStateChangeListener (AccessibilityManager.HighContrastTextStateChangeListener listener)
Unregisters a HighContrastTextStateChangeListener.
| Parameters | |
|---|---|
| listener | AccessibilityManager.HighContrastTextStateChangeListener: The listener.
 This value cannot benull. | 
removeTouchExplorationStateChangeListener
public boolean removeTouchExplorationStateChangeListener (AccessibilityManager.TouchExplorationStateChangeListener listener)
Unregisters a TouchExplorationStateChangeListener.
| Parameters | |
|---|---|
| listener | AccessibilityManager.TouchExplorationStateChangeListener: The listener.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | True if listener was previously registered. | 
sendAccessibilityEvent
public void sendAccessibilityEvent (AccessibilityEvent event)
Sends an AccessibilityEvent.
| Parameters | |
|---|---|
| event | AccessibilityEvent: The event to send. | 
| Throws | |
|---|---|
| IllegalStateException | if accessibility is not enabled.
 Note: The preferred mechanism for sending custom accessibility
 events is through calling ViewParent.requestSendAccessibilityEvent(View, AccessibilityEvent)instead of this method to allow predecessors to augment/filter events sent by
 their descendants. | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.
