Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

BiometricPrompt

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

A class that manages a system-provided biometric prompt. On devices running P and above, this will show a system-provided authentication prompt, using a device's supported biometric (fingerprint, iris, face, etc). On devices before P, this will show a dialog prompting for fingerprint authentication. The prompt will persist across orientation changes unless explicitly canceled by the client. For security reasons, the prompt will automatically dismiss when the activity is no longer in the foreground.

Summary

Nested classes
open

A wrapper class for the crypto objects supported by BiometricPrompt.

open

Container for callback data from authenticate(PromptInfo) and authenticate(PromptInfo, CryptoObject).

abstract

Callback structure provided to BiometricPrompt.

open

A class that contains a builder which returns the PromptInfo to be used in authenticate(PromptInfo, CryptoObject) and authenticate(PromptInfo).

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

Constructs a BiometricPrompt which can be used to prompt the user for authentication.

Public methods
open Unit

Cancels the biometric authentication, and dismisses the dialog upon confirmation from the biometric service.

open Unit

Shows the biometric prompt.

open Unit

Shows the biometric prompt.

Public constructors

<init>

BiometricPrompt(@NonNull fragmentActivity: FragmentActivity, @NonNull executor: Executor, @NonNull callback: BiometricPrompt.AuthenticationCallback)

Constructs a BiometricPrompt which can be used to prompt the user for authentication. The authenticaton prompt created by BiometricPrompt#authenticate(PromptInfo, CryptoObject) and BiometricPrompt#authenticate(PromptInfo) will persist across device configuration changes by default. If authentication is in progress, re-creating the BiometricPrompt can be used to update the Executor and AuthenticationCallback. This should be used to update the AuthenticationCallback after configuration changes. such as FragmentActivity#onCreate(Bundle).

Parameters
fragmentActivity FragmentActivity: A reference to the client's activity.
executor FragmentActivity: An executor to handle callback events.
callback FragmentActivity: An object to receive authentication events.

Public methods

cancelAuthentication

open fun cancelAuthentication(): Unit

Cancels the biometric authentication, and dismisses the dialog upon confirmation from the biometric service.

authenticate

open fun authenticate(@NonNull info: BiometricPrompt.PromptInfo, @NonNull crypto: BiometricPrompt.CryptoObject): Unit

Shows the biometric prompt. The prompt survives lifecycle changes by default. To cancel the authentication, use cancelAuthentication().

Parameters
info BiometricPrompt.PromptInfo: The information that will be displayed on the prompt. Create this object using BiometricPrompt.PromptInfo.Builder.
crypto BiometricPrompt.PromptInfo: The crypto object associated with the authentication.

authenticate

open fun authenticate(@NonNull info: BiometricPrompt.PromptInfo): Unit

Shows the biometric prompt. The prompt survives lifecycle changes by default. To cancel the authentication, use cancelAuthentication().

Parameters
info BiometricPrompt.PromptInfo: The information that will be displayed on the prompt. Create this object using BiometricPrompt.PromptInfo.Builder.