How to get list of available biometric sensors in an android device (any tweaks as documentation doesn't state any)
Asked Answered
L

1

1

Is there any way to get a list of biometric sensors which are already configured in the device.
For example if there are all sensors configured like;

  • iris
  • fingerprint
  • face

I find all 3, but if any one of the 3 is configured, I want to get the one configured e.g. fingerprint

I have searched the docs but didn't find any clues other than we will get one but which one is never mentioned.
Any solution to solve the above problem would be very helpful.

For my curiosity why can't android provide the configured sensors, like we get when we require runtime permission?

Secondly how they prioritize the sensors if all 3 are configured?

Longlongan answered 7/5, 2020 at 7:24 Comment(3)
Unfortunately, when you use BiometricPrompt you have no control over which kind of biometric that will be used. Well, in Android R you can select whether or not you want to allow "Weak" biometrics (as defined in the Android CDD), but you can't specify fingerprint or face for example.Christianachristiane
"how they prioritize the sensors if all 3 are configured" AFAIK, if the device supports multiple biometrics (e.g. both fingerprint and face), there'll be some kind of setting in the Settings app where the user can select their preferred biometric.Christianachristiane
So does it depends on the device as when I use S10 (Pie) I can able to authenticate face and Biometric prompt is also showing with all details like title, description, etc but in OnePlus 6T(Pie) neither face authentication is working nor Biometric prompt is showing with provided details.Longlongan
P
1

You can find the available sensors in the PackageManager, but please note that face recognition and iris were added in Android 10.

val packageManager = context?.packageManager
if (packageManager?.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) == true) {
        Toast.make(context, "Fingerprint sensor found!", Toast.LENGTH_SHORT).show()
    }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    if (packageManager?.hasSystemFeature(PackageManager.FEATURE_FACE) == true) {
        Toast.make(context, "Face sensor found!", Toast.LENGTH_SHORT).show()
    }
    if (packageManager?.hasSystemFeature(PackageManager.FEATURE_IRIS) == true) {
        Toast.make(context, "Iris sensor found!", Toast.LENGTH_SHORT).show()
    }
}
Patsy answered 11/8, 2022 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.