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

Class2BiometricAuthPrompt

open class Class2BiometricAuthPrompt
kotlin.Any
   ↳ androidx.biometric.auth.Class2BiometricAuthPrompt

An authentication prompt that requires the user to present a Class 2 biometric (e.g. fingerprint, face, or iris).

Note that Class 3 biometrics are guaranteed to meet the requirements for Class 2 and thus will also be accepted.

Summary

Nested classes

Builder for a Class2BiometricAuthPrompt with configurable options.

Public methods
open CharSequence?

Gets the description to be displayed on the prompt, if set.

open CharSequence

Gets the label text for the negative button on the prompt.

open CharSequence?

Gets the subtitle to be displayed on the prompt, if set.

open CharSequence

Gets the title to be displayed on the prompt.

open Boolean

Checks if the prompt should require explicit user confirmation after a passive biometric (e.g. iris or face) has been recognized but before

open AuthPrompt
startAuthentication(@NonNull host: AuthPromptHost, @NonNull callback: AuthPromptCallback)

Shows an authentication prompt to the user.

open AuthPrompt
startAuthentication(@NonNull host: AuthPromptHost, @NonNull executor: Executor, @NonNull callback: AuthPromptCallback)

Shows an authentication prompt to the user.

Extension functions
From androidx.biometric.auth
suspend BiometricPrompt.AuthenticationResult

Shows an authentication prompt to the user.

Public methods

getDescription

@Nullable open fun getDescription(): CharSequence?

Gets the description to be displayed on the prompt, if set.

Return
CharSequence? The description for the prompt.

getNegativeButtonText

@NonNull open fun getNegativeButtonText(): CharSequence

Gets the label text for the negative button on the prompt.

Return
CharSequence The negative button text for the prompt.

getSubtitle

@Nullable open fun getSubtitle(): CharSequence?

Gets the subtitle to be displayed on the prompt, if set.

Return
CharSequence? The subtitle for the prompt.

getTitle

@NonNull open fun getTitle(): CharSequence

Gets the title to be displayed on the prompt.

Return
CharSequence The title for the prompt.

isConfirmationRequired

open fun isConfirmationRequired(): Boolean

Checks if the prompt should require explicit user confirmation after a passive biometric (e.g. iris or face) has been recognized but before AuthPromptCallback#onAuthenticationSucceeded(androidx.fragment.app.FragmentActivity, * BiometricPrompt.AuthenticationResult) is called.

Return
Boolean Whether the prompt should require explicit user confirmation for passive biometrics.

startAuthentication

@NonNull open fun startAuthentication(
    @NonNull host: AuthPromptHost,
    @NonNull callback: AuthPromptCallback
): AuthPrompt

Shows an authentication prompt to the user.

Parameters
host AuthPromptHost: A wrapper for the component that will host the prompt.
callback AuthPromptCallback: The callback object that will receive and process authentication events. Each callback method will be run on the main thread.
Return
AuthPrompt A handle to the shown prompt.

startAuthentication

@NonNull open fun startAuthentication(
    @NonNull host: AuthPromptHost,
    @NonNull executor: Executor,
    @NonNull callback: AuthPromptCallback
): AuthPrompt

Shows an authentication prompt to the user.

Parameters
host AuthPromptHost: A wrapper for the component that will host the prompt.
executor Executor: The executor that will be used to run authentication callback methods.
callback AuthPromptCallback: The callback object that will receive and process authentication events.
Return
AuthPrompt A handle to the shown prompt.