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

BiometricManager

open class BiometricManager
kotlin.Any
   ↳ 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 android.hardware.biometrics.BiometricManager. On Android 9.0 (API 28) and prior versions, this will query androidx.core.hardware.fingerprint.FingerprintManagerCompat.

Summary

Nested classes
abstract

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

Constants
static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Unable to determine whether the user can authenticate.

static Int

The user can successfully authenticate.

Public methods
open Int

Checks if the user can authenticate with biometrics.

open Int
canAuthenticate(authenticators: Int)

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

open static BiometricManager
from(@NonNull context: Context)

Creates a BiometricManager instance from the given context.

Constants

BIOMETRIC_ERROR_HW_UNAVAILABLE

static val BIOMETRIC_ERROR_HW_UNAVAILABLE: Int

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

Value: 1

BIOMETRIC_ERROR_NONE_ENROLLED

static val BIOMETRIC_ERROR_NONE_ENROLLED: Int

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

Value: 11

BIOMETRIC_ERROR_NO_HARDWARE

static val BIOMETRIC_ERROR_NO_HARDWARE: Int

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

Value: 12

BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED

static val BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED: Int

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.

Value: 15

BIOMETRIC_ERROR_UNSUPPORTED

static val BIOMETRIC_ERROR_UNSUPPORTED: Int

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

Value: -2

BIOMETRIC_STATUS_UNKNOWN

static val BIOMETRIC_STATUS_UNKNOWN: Int

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.

Value: -1

BIOMETRIC_SUCCESS

static val BIOMETRIC_SUCCESS: Int

The user can successfully authenticate.

Value: 0

Public methods

canAuthenticate

open fun canAuthenticate(): Int

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.

Return
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

open fun canAuthenticate(authenticators: Int): Int

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 Authenticators that may be used for authentication.
Return
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

@NonNull open static fun from(@NonNull context: Context): BiometricManager

Creates a BiometricManager instance from the given context.

Parameters
context Context: The application or activity context.
Return
BiometricManager An instance of BiometricManager.