public class

BiometricPrompt.PromptInfo.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.biometric.BiometricPrompt.PromptInfo.Builder

Overview

A builder used to set individual options for the BiometricPrompt.PromptInfo class.

Summary

Constructors
publicBuilder()

Methods
public BiometricPrompt.PromptInfobuild()

Creates a BiometricPrompt.PromptInfo object with the specified options.

public BiometricPrompt.PromptInfo.BuildersetAllowedAuthenticators(int allowedAuthenticators)

Optional: Specifies the type(s) of authenticators that may be invoked by BiometricPrompt to authenticate the user.

public BiometricPrompt.PromptInfo.BuildersetConfirmationRequired(boolean confirmationRequired)

Optional: Sets a system hint for whether to require explicit user confirmation after a passive biometric (e.g.

public BiometricPrompt.PromptInfo.BuildersetDescription(java.lang.CharSequence description)

Optional: Sets the description for the prompt.

public BiometricPrompt.PromptInfo.BuildersetDeviceCredentialAllowed(boolean deviceCredentialAllowed)

Optional: Sets whether the user should be given the option to authenticate with their device PIN, pattern, or password instead of a biometric.

public BiometricPrompt.PromptInfo.BuildersetNegativeButtonText(java.lang.CharSequence negativeButtonText)

Required: Sets the text for the negative button on the prompt.

public BiometricPrompt.PromptInfo.BuildersetSubtitle(java.lang.CharSequence subtitle)

Optional: Sets the subtitle for the prompt.

public BiometricPrompt.PromptInfo.BuildersetTitle(java.lang.CharSequence title)

Required: Sets the title for the prompt.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Methods

public BiometricPrompt.PromptInfo.Builder setTitle(java.lang.CharSequence title)

Required: Sets the title for the prompt.

Parameters:

title: The title to be displayed on the prompt.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setSubtitle(java.lang.CharSequence subtitle)

Optional: Sets the subtitle for the prompt.

Parameters:

subtitle: The subtitle to be displayed on the prompt.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setDescription(java.lang.CharSequence description)

Optional: Sets the description for the prompt.

Parameters:

description: The description to be displayed on the prompt.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setNegativeButtonText(java.lang.CharSequence negativeButtonText)

Required: Sets the text for the negative button on the prompt.

Note that this option is incompatible with device credential authentication and must NOT be set if the latter is enabled via BiometricPrompt.PromptInfo.Builder.setAllowedAuthenticators(int) or BiometricPrompt.PromptInfo.Builder.setDeviceCredentialAllowed(boolean).

Parameters:

negativeButtonText: The label to be used for the negative button on the prompt.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setConfirmationRequired(boolean confirmationRequired)

Optional: Sets a system hint for whether to require explicit user confirmation after a passive biometric (e.g. iris or face) has been recognized but before BiometricPrompt.AuthenticationCallback is called. Defaults to true.

Disabling this option is generally only appropriate for frequent, low-value transactions, such as re-authenticating for a previously authorized application.

Also note that, as it is merely a hint, this option may be ignored by the system. For example, the system may choose to instead always require confirmation if the user has disabled passive authentication for their device in Settings. Additionally, this option will be ignored on devices running OS versions prior to Android 10 (API 29).

Parameters:

confirmationRequired: Whether this option should be enabled.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setDeviceCredentialAllowed(boolean deviceCredentialAllowed)

Deprecated: Use BiometricPrompt.PromptInfo.Builder.setAllowedAuthenticators(int) instead.

Optional: Sets whether the user should be given the option to authenticate with their device PIN, pattern, or password instead of a biometric. Defaults to false.

Note that this option is incompatible with BiometricPrompt.PromptInfo.Builder.setNegativeButtonText(CharSequence) and must NOT be enabled if the latter is set.

Before enabling this option, developers should check whether the device is secure by calling . If the device is not secure, authentication will fail with BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL.

On versions prior to Android 10 (API 29), calls to BiometricPrompt.cancelAuthentication() will not work as expected after the user has chosen to authenticate with their device credential. This is because the library internally launches a separate activity (by calling ) that does not have a public API for cancellation.

Parameters:

deviceCredentialAllowed: Whether this option should be enabled.

Returns:

This builder.

public BiometricPrompt.PromptInfo.Builder setAllowedAuthenticators(int allowedAuthenticators)

Optional: Specifies the type(s) of authenticators that may be invoked by BiometricPrompt to authenticate the user. Available authenticator types are defined in BiometricManager.Authenticators and can be combined via bitwise OR. Defaults to:

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. Setting an unsupported value on an affected Android version will result in an error when calling BiometricPrompt.PromptInfo.Builder.build().

This method should be preferred over BiometricPrompt.PromptInfo.Builder.setDeviceCredentialAllowed(boolean) and overrides the latter if both are used. Using this method to enable device credential authentication (with BiometricManager.Authenticators.DEVICE_CREDENTIAL) will replace the negative button on the prompt, making it an error to also call BiometricPrompt.PromptInfo.Builder.setNegativeButtonText(CharSequence).

If this method is used and no authenticator of any of the specified types is available at the time authenticate() is called, BiometricPrompt.AuthenticationCallback.onAuthenticationError(int, CharSequence) will be invoked with an appropriate error code.

Parameters:

allowedAuthenticators: A bit field representing all valid authenticator types that may be invoked by the prompt.

Returns:

This builder.

Creates a BiometricPrompt.PromptInfo object with the specified options.

Returns:

The BiometricPrompt.PromptInfo object.