You are looking for the wrong place. When onAccessibilityEvent
receives the event, the action is already completed. It simply informs you that a click event has occurred. It is already too late to stop him.
You really need TouchExplorationMode. TalkBack processing is implemented quickly and dirty here, and how it makes the user interface behave the way it does without a lot of unwanted message processing and exceptions. I used only part of this thing for this function. There, of course, there are many other necessary forests, but this would distract from the key elements.
The contents of serviceConfig.xml:
<?xml version="1.0" encoding="utf-8"?> <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" android:accessibilityEventTypes="typeAllMask" android:accessibilityFlags="flagRequestTouchExplorationMode" android:canRequestTouchExplorationMode="true" />
Partial Content A11yService.java
@Override public void onAccessibilityEvent(AccessibilityEvent e) { switch (e.getEventType()) { case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: { e.getSource().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } } }
TalkBack then intercepts gestures in onGesture, and to scroll right or swipe left, grabs them and performs the same action (accessibility focus) only on the next or previous element, bypassing AccessibilityNode. Easy peasy!
source share