'AccessibilityService on android studio doesn't work

i need to initialise an AccessibilityService with xml configuration, but the service doens't work... i don't understand why. can you help me ?

code :

manifest :

        <service android:name=".AccessibilityServiceTest"
        android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
        android:label="@string/accessibility_service_label"
        android:exported="true">
        <intent-filter>
            <action android:name="android.accessibilityservice.AccessibilityService" />
        </intent-filter>
        <meta-data
            android:name="android.accessibilityservicetest"
            android:resource="@xml/accessibility_service_config" />
    </service>

xml :

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="50"
android:canRetrieveWindowContent="true"
android:accessibilityEventTypes="typeAllMask"
android:settingsActivity="com.example.android.accessibility.ServiceSettingsActivity"
android:accessibilityFlags="flagDefault"
/>

class :

public class AccessibilityServiceTest extends AccessibilityService {

private static final String TAG = "myService";

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    Log.e(TAG, "event : " + event);

    //if (getRootInActiveWindow () == null) { return; }

    //AccessibilityNodeInfoCompat rootInActiveWindow = AccessibilityNodeInfoCompat.wrap(getRootInActiveWindow());

}

@Override
public void onInterrupt() {

    Log.e(TAG, "interrupt...");
}
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source