2

With an accessibility service, double tapping activate the last element focused by the accessibility service.

I just want to handle this event with my accessibility service but there is no listener/event for that. I only get two accessibility event of type "TYPE_TOUCH_INTERACTION_END".

I found a class in Android with a DoubleTapDetector but it's not accessible from the Android API: TouchExplorer.java (see inner class DoubleTapDetector)

rds
  • 26,253
  • 19
  • 107
  • 134
probitaille
  • 1,899
  • 1
  • 19
  • 37
  • You can't handle double-tap events in an accessibility service. The events are captured by the accessibility framework, which simulates a DOWN/UP event pair. – alanv Oct 08 '14 at 20:49
  • I thought about a timer between two up event but it's really risky and don't think it's a good practice. I want to be sure that I can execute actions at the same time that an element is activated by double tap. – probitaille Oct 08 '14 at 21:04
  • What about using CLICKED events as an indication that something was activated? – alanv Oct 08 '14 at 21:08
  • Because double tap does not only generate clicked events. By example with an accessible service, a double tap on textView will change the input focus and don't generate a click event. The Android doc says: "double-tap anywhere on the screen activate the focused item." But there's no global "Activate event". – probitaille Oct 09 '14 at 15:27
  • can I see your .xml file for accessibility which is available in xml folder? – Sanjay Kumaar Nov 29 '22 at 07:38
  • @SanjayKumaar Sadly, I don't have access to this project anymore. It was 8 years ago. – probitaille Dec 01 '22 at 19:50
  • @probitaille you still need answer of this? – Sanjay Kumaar Dec 21 '22 at 05:24
  • @Sanjay Kumaar An answer will always help someone who is looking for a similar question. – probitaille Dec 26 '22 at 04:45
  • 1
    @probitaille there might be issue in accessibility .xml (accessibility-service) file. I'm sharing xml file in answer. – Sanjay Kumaar Dec 30 '22 at 05:41

1 Answers1

1

This might be useful. Try this,

Add this in AndroidManifest.xml

<service
            android:name="com.example.Accessibility"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service" />
</service>

accessibility_service.xml in xml folder

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
 android:accessibilityEventTypes="typeViewFocused|typeViewTextChanged|typeViewClicked|typeWindowStateChanged|typeWindowContentChanged|typeWindowsChanged"
    android:accessibilityFeedbackType="feedbackGeneric|feedbackVisual"
    android:canRetrieveWindowContent="true"
    android:accessibilityFlags="flagReportViewIds|flagIncludeNotImportantViews"
    android:description="@string/app_name"
    android:canPerformGestures="true"
    android:notificationTimeout="150">
</accessibility-service>
Sanjay Kumaar
  • 690
  • 7
  • 17