BiometricPrompt

public class BiometricPrompt
extends Object

java.lang.Object
   ↳ 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

class BiometricPrompt.AuthenticationCallback

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

class BiometricPrompt.AuthenticationResult

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

class BiometricPrompt.CryptoObject

A wrapper class for the crypto objects supported by BiometricPrompt

class BiometricPrompt.PromptInfo

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

</

Constants

int AUTHENTICATION_RESULT_TYPE_BIOMETRIC

Authentication type reported by BiometricPrompt.AuthenticationResult when the user authenticated by presenting some form of biometric (e.g.

int AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL

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

int AUTHENTICATION_RESULT_TYPE_UNKNOWN

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

int ERROR_CANCELED

The operation was canceled because the biometric sensor is unavailable.

int ERROR_HW_NOT_PRESENT

The device does not have the required authentication hardware.

int ERROR_HW_UNAVAILABLE

The hardware is unavailable.

int ERROR_LOCKOUT

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

int ERROR_LOCKOUT_PERMANENT

The operation was canceled because ERROR_LOCKOUT occurred too many times.