Google is committed to advancing racial equity for Black communities. See how.

BiometricManager

public class BiometricManager
extends Object

java.lang.Object
   ↳ androidx.biometric.BiometricManager


A class that provides system information related to biometrics (e.g. fingerprint, face, etc.).

On devices running Android 10 (API 29) and above, this will query the framework's version of BiometricManager. On Android 9.0 (API 28) and prior versions, this will query FingerprintManagerCompat.

Summary

Nested classes

interface BiometricManager.Authenticators

Types of authenticators, defined at a level of granularity supported by BiometricManager and BiometricPrompt

Constants

int BIOMETRIC_ERROR_HW_UNAVAILABLE

The user can't authenticate because the hardware is unavailable.

int BIOMETRIC_ERROR_NONE_ENROLLED

The user can't authenticate because no biometric or device credential is enrolled.

int BIOMETRIC_ERROR_NO_HARDWARE

The user can't authenticate because there is no suitable hardware (e.g.

int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED

The user can't authenticate because a security vulnerability has been discovered with one or more hardware sensors.

int BIOMETRIC_ERROR_UNSUPPORTED

The user can't authenticate because the specified options are incompatible with the current Android version.

int BIOMETRIC_STATUS_UNKNOWN

Unable to determine whether the user can authenticate.

int BIOMETRIC_SUCCESS

The user can successfully authenticate.

Public methods

int canAuthenticate()

This method is deprecated. Use canAuthenticate(int) instead.

int canAuthenticate(int authenticators)

Checks if the user can authenticate with an authenticator that meets the given requirements.

static BiometricManager from(Context context)

Creates a BiometricManager instance from the given context.

Inherited methods

Constants

BIOMETRIC_ERROR_HW_UNAVAILABLE

public static final int BIOMETRIC_ERROR_HW_UNAVAILABLE

The user can't authenticate because the hardware is unavailable. Try again later.

Constant Value: 1 (0x00000001)

BIOMETRIC_ERROR_NONE_ENROLLED

public static final int BIOMETRIC_ERROR_NONE_ENROLLED

The user can't authenticate because no biometric or device credential is enrolled.

Constant Value: 11 (0x0000000b)

BIOMETRIC_ERROR_NO_HARDWARE

public static final int BIOMETRIC_ERROR_NO_HARDWARE

The user can't authenticate because there is no suitable hardware (e.g. no biometric sensor or no keyguard).

Constant Value: 12 (0x0000000c)

BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED

public static final int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED

The user can't authenticate because a security vulnerability has been discovered with one or more hardware sensors. The affected sensor(s) are unavailable until a security update has addressed the issue.

Constant Value: 15 (0x0000000f)

BIOMETRIC_ERROR_UNSUPPORTED

public static final int BIOMETRIC_ERROR_UNSUPPORTED

The user can't authenticate because the specified options are incompatible with the current Android version.

Constant Value: -2 (0xfffffffe)

BIOMETRIC_STATUS_UNKNOWN

public static final int BIOMETRIC_STATUS_UNKNOWN

Unable to determine whether the user can authenticate.

This status code may be returned on older Android versions due to partial incompatibility with a newer API. Applications that wish to enable biometric authentication on affected devices may still call BiometricPrompt#authenticate() after receiving this status code but should be prepared to handle possible errors.

Constant Value: -1 (0xffffffff)

BIOMETRIC_SUCCESS

public static final int BIOMETRIC_SUCCESS

The user can successfully authenticate.

Constant Value: 0 (0x00000000)

Public methods

canAuthenticate

public int canAuthenticate ()

This method is deprecated.
Use canAuthenticate(int) instead.

Checks if the user can authenticate with biometrics. This requires at least one biometric sensor to be present, enrolled, and available on the device.

Returns
int BIOMETRIC_SUCCESS if the user can authenticate with biometrics. Otherwise, returns an error code indicating why the user can't authenticate, or BIOMETRIC_STATUS_UNKNOWN if it is unknown whether the user can authenticate.

canAuthenticate

public int canAuthenticate (int authenticators)

Checks if the user can authenticate with an authenticator that meets the given requirements. This requires at least one of the specified authenticators to be present, enrolled, and available on the device.

Note that not all combinations of authenticator types are supported prior to Android 11 (API 30). Specifically, DEVICE_CREDENTIAL alone is unsupported prior to API 30, and BIOMETRIC_STRONG | DEVICE_CREDENTIAL is unsupported on API 28-29. Developers that wish to check for the presence of a PIN, pattern, or password on these versions should instead use KeyguardManager.isDeviceSecure().

Parameters
authenticators int: A bit field representing the types of BiometricManager.Authenticators that may be used for authentication.

Returns
int BIOMETRIC_SUCCESS if the user can authenticate with an allowed authenticator. Otherwise, returns BIOMETRIC_STATUS_UNKNOWN or an error code indicating why the user can't authenticate.

from

public static BiometricManager from (Context context)

Creates a BiometricManager instance from the given context.

Parameters
context Context: The application or activity context.

Returns
BiometricManager An instance of BiometricManager.