I am registering an AccessibilityService to listen for app changes. It works on all the phones I've tested but on the Galaxy A3 with Android 5.0 is failing because AccessibilityEvent.getPackageName() is returning null. The packageName should be set, as it is a regular app, downloaded from Google play, being interacted with.
Does anyone know why is this and how to fix it?
Below the relevant parts of my code.
<service
android:name=".presentation.view.services.LockService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config"/>
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService"/>
</intent-filter>
</service>
@Override
public void onServiceConnected() {
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
info.notificationTimeout = 100;
this.setServiceInfo(info);
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
event.getPackageName() // returns NULL;
}