3

I am doing login validation with Biometric prompt dependency:usedandroidx.biometric:biometric-ktx:1.2.0-alpha04 checked the hardware supported or not using this code

fun isBiometricHardWareAvailable(con: Context): Boolean {
var result = false
val biometricManager = BiometricManager.from(con)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
    when (biometricManager.canAuthenticate(BiometricManager.Authenticators.DEVICE_CREDENTIAL or BiometricManager.Authenticators.BIOMETRIC_STRONG)) {
        BiometricManager.BIOMETRIC_SUCCESS -> result = true
        BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> result = false
        BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> result = false
        BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> result = false
        BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED ->
            result = true
        BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED ->
            result = true
        BiometricManager.BIOMETRIC_STATUS_UNKNOWN ->
            result = false
    }
} else {
    when (biometricManager.canAuthenticate()) {
        BiometricManager.BIOMETRIC_SUCCESS -> result = true
        BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> result = false
        BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> result = false
        BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> result = false
        BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED -> result = false
        BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> result = false
        BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> result = false
    }
}
return result}

Checked this code with Samsung S10 mobile both Fignerprint and faceId working fine.My device(Tablet) have only on FaceId how to check with faceId? Default BiometricPrompt not shown in Tablet while have only FaceId My Refrence Link:BioMetric

0 Answers0