androidaccessibilityserviceaccessibilityaccessibility-api

Accessibility service: get views you can interact with instantly (same as Voice Access)?


The goal is to obtain views that can be interacted with instantly (that can be clicked right now and something would happen). If the view is visible and clickable in general but hovered by another view/menu/side panel, it should be omitted.

Voice Access do that. And it seems to use Accessibility API.

The perfect example is the bottom menu in Google Maps. When it expands, "Search along the route" button underneath is still visible but it's not highlighted by the app.


So what do we have?

What I'm missing?


enter image description here


Solution

  • The key point is that in an AccessibilityService.onAccessibilityEvent() the tree hierarchy is not final. To get views that are interactable at the moment, AccessibilityService.getRootInActiveWindow() should be called with a delay.