1 year ago

#270343

test-img

Sparsh Dutta

Detect separately for availability of fingerprint and face authentication biometrics

My requirement is that if face authentication is available in user's phone, I'll prompt the user for enabling face recognition, and I won't prompt for fingerprint authentication. But if face authentication is not available in user's phone, or if the user denies the option to enable face authentication, I'll prompt the user for enabling fingerprint authentication.

We can detect the availability of biometrics (as a whole) with:

val biometricManager = BiometricManager.from(this)
when (biometricManager.canAuthenticate(BIOMETRIC_STRONG or DEVICE_CREDENTIAL)) {
    BiometricManager.BIOMETRIC_SUCCESS ->
        Log.d("MY_APP_TAG", "App can authenticate using biometrics.")
    BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->
        Log.e("MY_APP_TAG", "No biometric features available on this device.")
    BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ->
        Log.e("MY_APP_TAG", "Biometric features are currently unavailable.")
    BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> {
        // Prompts the user to create credentials that your app accepts.
        val enrollIntent = Intent(Settings.ACTION_BIOMETRIC_ENROLL).apply {
            putExtra(Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED,
                BIOMETRIC_STRONG or DEVICE_CREDENTIAL)
        }
        startActivityForResult(enrollIntent, REQUEST_CODE)
    }
}

But how do I detect availability of fingerprint and availability of face authentication separately, so that I can display the prompts accordingly?

android

face-recognition

android-fingerprint-api

android-biometric-prompt

android-biometric

0 Answers

Your Answer

Accepted video resources