I am trying to implement an AccessibilityService. I have shared my code below.
When I turn on my accessibility service from settings menu then onServiceConnected() is called but onAccessibiltyEvent() is not called at all. Please guide me on this.
Service Declaration in manifest file.
<service
            android:name=".MyAccessibilityService"
            android:enabled="true"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>
            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service_config" />
</service>
XML file
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:description="@string/accessibility_service_description"
    android:accessibilityEventTypes="typeAllMask"
    android:canRequestFilterKeyEvents="true"
    android:accessibilityFlags="flagDefault"
    android:notificationTimeout="100"
    android:canRetrieveWindowContent="true"
    />
MyAccessibiltyService.java
public class MyAccessibilityService extends AccessibilityService {
    @Override
    protected void onServiceConnected() {
        super.onServiceConnected();
        Log.d(TAG,"Service Connected");
    }
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
        System.out.println("Event Occurred");
        Log.d(TAG, "onAccessibilityEvent: event=" + event);
        AccessibilityNodeInfo nodeInfo = event.getSource();
        if (null == nodeInfo) return;
    }
    @Override
    public void onInterrupt() {
        Log.d(TAG,"Accessibility Interrupted" );
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG,"Service Destroyed");
    }
}
Please note that I have already checked all stackoverflow answers hence do not mark this as duplicate.