Android 12 Developer Preview is here! Try it out, and give us your feedback!

BiometricPrompt

open class BiometricPrompt
kotlin.Any
   ↳ androidx.biometric.BiometricPrompt

A class that manages a system-provided biometric prompt. On devices running Android 9.0 (API 28) and above, this will show a system-provided authentication prompt, using one of the device's supported biometric modalities (fingerprint, iris, face, etc). Prior to Android 9.0, this will instead show a custom fingerprint authentication dialog. The prompt will persist across configuration changes unless explicitly canceled. For security reasons, the prompt will be dismissed when the client application is no longer in the foreground.

To persist authentication across configuration changes, developers should (re)create the prompt every time the activity/fragment is created. Instantiating the prompt with a new callback early in the fragment/activity lifecycle (e.g. in onCreate()) will allow the ongoing authentication session's callbacks to be received by the new fragment/activity instance. Note that cancelAuthentication() should not be called, and authenticate() does not need to be invoked during activity/fragment creation.

Summary

Nested classes
abstract

A collection of methods that may be invoked by BiometricPrompt during authentication.

open

A container for data passed to AuthenticationCallback#onAuthenticationSucceeded( * AuthenticationResult) when the user has successfully authenticated.

open

A wrapper class for the crypto objects supported by BiometricPrompt.

open

A set of configurable options for how the BiometricPrompt should appear and behave.

Constants
static Int

Authentication type reported by AuthenticationResult when the user authenticated by presenting some form of biometric (e.g. fingerprint or face).

static Int

Authentication type reported by AuthenticationResult when the user authenticated by entering their device PIN, pattern, or password.

static Int

Authentication type reported by AuthenticationResult when the user authenticated via an unknown method.

static Int

The operation was canceled because the biometric sensor is unavailable.

static Int

The device does not have the required authentication hardware.

static Int

The hardware is unavailable.

static Int

The operation was canceled because the API is locked out due to too many attempts.

static Int

The operation was canceled because ERROR_LOCKOUT occurred too many times.

static Int

The user pressed the negative button.

static Int

The user does not have any biometrics enrolled.

static Int

The device does not have pin, pattern, or password set up.

static Int

The operation can't be completed because there is not enough device storage remaining.

static Int

A security vulnerability has been discovered with one or more hardware sensors.

static Int

The current operation has been running too long and has timed out.

static Int

The sensor was unable to process the current image.

static Int

The user canceled the operation.

static Int

The operation failed due to a vendor-specific error.

Public constructors
<init>(@NonNull activity: FragmentActivity, @NonNull callback: BiometricPrompt.AuthenticationCallback)

Constructs a BiometricPrompt, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face.

<init>(@NonNull fragment: Fragment, @NonNull callback: BiometricPrompt.AuthenticationCallback)

Constructs a BiometricPrompt, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face.

<init>(@NonNull activity: FragmentActivity, @NonNull executor: Executor, @NonNull callback: BiometricPrompt.AuthenticationCallback)

Constructs a BiometricPrompt, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face.

<init>(@NonNull fragment: Fragment, @NonNull executor: Executor, @NonNull callback: BiometricPrompt.AuthenticationCallback)

Constructs a BiometricPrompt, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face.

Public methods
open Unit

Shows the biometric prompt to the user.

open Unit

Shows the biometric prompt to the user.

open Unit

Cancels the ongoing authentication session and dismisses the prompt.

Constants

AUTHENTICATION_RESULT_TYPE_BIOMETRIC

static val AUTHENTICATION_RESULT_TYPE_BIOMETRIC: Int

Authentication type reported by AuthenticationResult when the user authenticated by presenting some form of biometric (e.g. fingerprint or face).

Value: 2

AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL