I'm trying to create an accessibility service that listens for fingerprint gesture swipes, however when I try to detect if gesture detection is available (using the isGestureDectionAvailable
method), my app crashes and gives me a null object error, claiming that getFingerprintGestureController()
is returning null.
Here is the snippet of code in my service's onCreate
method that seems to be causing the error (Kotlin code, so fingerprintGestureController is the getFingerprintGestureController()
call):
override fun onCreate() {
super.onCreate()
gestureController = fingerprintGestureController
gestureDetectionAvailable = gestureController.isGestureDetectionAvailable
if (!gestureDetectionAvailable) {
return
}
…
}
And the error that follows:
java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.accessibilityservice.IAccessibilityServiceConnection.isFingerprintGestureDetectionAvailable()' on a null object reference …
Any idea why getFingerprintGestureController()
isn't returning the controller object? I'm testing on a Pixel and have granted the app accessibility access in the settings.