i'm trying to create an accessibility service to use the autofill feature in the browsers on android.
My project is a flutter project but i'm currently working on my service in Kotlin. My problem is that the function 'onAccessibilityEvent' in my service is never called. I've been searching for days on Stackoverflow but none of the solutions worked for me. The function 'onServiceConnected' is called.
My service class:
class PasswordAutofillAccessService: AccessibilityService() {
override fun onServiceConnected() {
print("test service connected")
super.onServiceConnected()
}
override fun onInterrupt() {
print("test interrupt")
}
override fun onUnbind(intent: Intent?): Boolean {
print("test unbind")
return super.onUnbind(intent)
}
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
print("test event")
}
override fun onRebind(intent: Intent?) {
super.onRebind(intent)
}
}
My accessibility service configuration XML:
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewFocused|typeViewClicked"
android:accessibilityFeedbackType="feedbackAllMask"
android:canRequestEnhancedWebAccessibility="true"
android:notificationTimeout="100"
android:packageNames="net.company.my_app"
android:description="@string/serviceDescription"
android:canRetrieveWindowContent="true"
android:accessibilityFlags="flagRetrieveInteractiveWindows"
android:settingsActivity="net.company.my_app.AuthenticateActivity"
/>
In the AndroidManifest:
<service android:name=".PasswordAutofillAccessService"
android:enabled="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:label="Test app">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service" />
</service>
I'm currently testing on a Pixel 3 with Android P (PQ3A.190705.003). I've tried with some others (API 26 & +) and it still have the problem.
Thanks for your help!