This question was unanswered for some times here and here, I'm trying to use that feature for my app and I've encountered this same problem and the solutions didn't work for me. there is a fact that the method returns true in the pixel device VM but it never returns true in my Samsung device (SM-A205F). I've tested the code on many other devices too but the same problem still exists (their producer was Samsung too). the devices support Finger Print Gesture Detection too (it is possible to open the notification bar using finger print sensor gestures). Is it possible that the solution is adding a Samsung specific library to my code? I've seen this question too although it was somehow something else. I couldn't find the said library in the link's solution.
Manifest file:
<?xml version="1.0" encoding="utf-8"?><!--suppress DeprecatedClassUsageInspection -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taha.fgesture">
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<!-- <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />-->
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fgesture">
<service
android:name=".MyAccessibilityService"
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/myfingerprintgestureservice" />
</service>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
myfingerprintgestureservice xml file:
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagDefault|flagRequestFingerprintGestures"
android:canRequestFingerprintGestures="true"
android:canPerformGestures="true"
/>
MyAccessibilityService class:
@Override
protected void onServiceConnected() {
serviceInfo.eventTypes = AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FINGERPRINT_GESTURES;
serviceInfo.flags = AccessibilityServiceInfo.DEFAULT;
serviceInfo.flags = AccessibilityServiceInfo.FLAG_REQUEST_FINGERPRINT_GESTURES;
serviceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
//serviceInfo.notificationTimeout=100;
this.setServiceInfo(serviceInfo);
//Log.d(TAG, "onCreate: connected");
mGestureController = getFingerprintGestureController();
if (mGestureController != null) {
Log.d(TAG, "onServiceConnected: " + mGestureController);
isFingerprintGestureControllerConnected = true;
}
mIsGestureDetectionAvailable =
mGestureController.isGestureDetectionAvailable();
Log.d(TAG, "onServiceConnected: " + mGestureController.isGestureDetectionAvailable());
isGestureDetectionAvailable = mGestureController.isGestureDetectionAvailable();
mFingerprintGestureCallback =
new FingerprintGestureController.FingerprintGestureCallback() {
@Override
public void onGestureDetected(int gesture) {
detectedGesture = gesture;
switch (gesture) {
case FingerprintGestureController.FINGERPRINT_GESTURE_SWIPE_DOWN:
Log.d(TAG, "onGestureDetected: " + gesture);
break;
case FingerprintGestureController.FINGERPRINT_GESTURE_SWIPE_LEFT:
Log.d(TAG, "onGestureDetected: " + gesture);
break;
case FingerprintGestureController.FINGERPRINT_GESTURE_SWIPE_RIGHT:
Log.d(TAG, "onGestureDetected: " + gesture);
break;
case FingerprintGestureController.FINGERPRINT_GESTURE_SWIPE_UP:
Log.d(TAG, "onGestureDetected: " + gesture);
break;
default:
Log.e(TAG,
"Error: Unknown gesture type detected!");
break;
}
}
@Override
public void onGestureDetectionAvailabilityChanged(boolean available) {
//mIsGestureDetectionAvailable = available;
Log.d(TAG, "onGestureDetectionAvailabilityChanged: " + available);
}
};
try {
mGestureController.registerFingerprintGestureCallback(
mFingerprintGestureCallback, null);
Log.d(TAG, "onServiceConnected: Registered");
isRegistered = true;
} catch (Exception e) {
Log.d(TAG, "onServiceConnected: " + e.toString());
}
sendMessage();
if (mFingerprintGestureCallback != null) {
Log.d(TAG, "onServiceConnected: registered");
mGestureController.registerFingerprintGestureCallback(
mFingerprintGestureCallback, null);
}
if (mFingerprintGestureCallback != null
|| !mIsGestureDetectionAvailable) {
return;
}
}