Question: I'm asked to show certain UI elements depending on the presence of biometric hardware. For Android 23-27 I use `FingerprintManager#isHardwareDetected()` and `FingerprintManager#hasEnrolledFingerprints()`. Both of which are deprecated in Android 28.

I understand that I can get this information by using `BiometricPrompt#authenticate(...)` and receiving either `BiometricPrompt#BIOMETRIC_ERROR_HW_NOT_PRESENT` or `BiometricPrompt#BIOMETRIC_ERROR_NO_BIOMETRICS` in the `BiometricPrompt.AuthenticationCallback#onAuthenticationError(int errorCode, ...)` method. But this would lead to the `BiometricPrompt` being shown on supporting devices, which is undesirable. Using the `CancellationSignal` doesn't seem to be a solution either, since I wouldn't know when to cancel the prompt.

Is there any way to detect biometric hardware presence and user enrolment?

Answer: 
AndroidX biometric library started providing this kind of information from version `1.0.0-beta01` (`androidx.biometric:biometric:1.0.0-beta01`)

```
BiometricManager.from(context).canAuthenticate()

```

Which returns one of

* BIOMETRIC\_SUCCESS
* BIOMETRIC\_ERROR\_HW\_UNAVAILABLE
* BIOMETRIC\_ERROR\_NONE\_ENROLLED
* BIOMETRIC\_ERROR\_NO\_HARDWARE

**See changelog:**
<https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0-beta01>
For those who do not want to wait for support library released, you can use nightly build like this

```
repositories {
        maven {
            url "https://ci.android.com/builds/submitted/5795878/androidx_snapshot/latest/repository/"
        }
    }

implementation group: 'androidx.biometric', name: 'biometric', version: '1.0.0-SNAPSHOT'

```

get build version from here

```
https://ci.android.com/builds/branches/aosp-androidx-master-dev/

```

branch **aosp-androidx-master-dev**

show latest build from **androidx-snapshot**