# Print output for @column tags ?>
public
static
class
BiometricPrompt.Builder
extends Object
java.lang.Object | |
↳ | android.hardware.biometrics.BiometricPrompt.Builder |
A builder that collects arguments to be shown on the system-provided biometric dialog.
Public constructors | |
---|---|
Builder(Context context)
Creates a builder for a |
Public methods | |
---|---|
BiometricPrompt
|
build()
Creates a |
BiometricPrompt.Builder
|
setAllowedAuthenticators(int authenticators)
Optional: Specifies the type(s) of authenticators that may be invoked by
|
BiometricPrompt.Builder
|
setConfirmationRequired(boolean requireConfirmation)
Optional: Sets a hint to the system for whether to require user confirmation after authentication. |
BiometricPrompt.Builder
|
setDescription(CharSequence description)
Optional: Sets a description that will be shown on the prompt. |
BiometricPrompt.Builder
|
setDeviceCredentialAllowed(boolean allowed)
This method is deprecated.
Replaced by |
BiometricPrompt.Builder
|
setNegativeButton(CharSequence text, Executor executor, DialogInterface.OnClickListener listener)
Required: Sets the text, executor, and click listener for the negative button on the prompt. |
BiometricPrompt.Builder
|
setSubtitle(CharSequence subtitle)
Optional: Sets a subtitle that will be shown on the prompt. |
BiometricPrompt.Builder
|
setTitle(CharSequence title)
Required: Sets the title that will be shown on the prompt. |
Inherited methods | |
---|---|
public Builder (Context context)
Creates a builder for a BiometricPrompt
dialog.
Parameters | |
---|---|
context |
Context : The Context that will be used to build the prompt. |
public BiometricPrompt build ()
Creates a BiometricPrompt
.
Returns | |
---|---|
BiometricPrompt |
An instance of BiometricPrompt .
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
If any required fields are unset, or if given any invalid combination of field values. |
public BiometricPrompt.Builder setAllowedAuthenticators (int authenticators)
Optional: Specifies the type(s) of authenticators that may be invoked by
BiometricPrompt
to authenticate the user. Available authenticator types are
defined in Authenticators
and can be combined via bitwise OR. Defaults to:
Authenticators#BIOMETRIC_WEAK
for non-crypto authentication, orAuthenticators#BIOMETRIC_STRONG
for crypto-based authentication.If this method is used and no authenticator of any of the specified types is available
at the time BiometricPrompt#authenticate(...)
is called, authentication will
be canceled and AuthenticationCallback#onAuthenticationError(int, CharSequence)
will be invoked with an appropriate error code.
This method should be preferred over setDeviceCredentialAllowed(boolean)
and
overrides the latter if both are used. Using this method to enable device credential
authentication (with Authenticators#DEVICE_CREDENTIAL
) will replace the negative
button on the prompt, making it an error to also call
setNegativeButton(java.lang.CharSequence, java.util.concurrent.Executor, android.content.DialogInterface.OnClickListener)
.
If unlocking cryptographic operation(s), it is the application's responsibility to request authentication with the proper set of authenticators (e.g. match the authenticators specified during key generation).
Parameters | |
---|---|
authenticators |
int : A bit field representing all valid authenticator types that may be
invoked by the prompt.
Value is either 0 or a combination of BiometricManager.Authenticators.BIOMETRIC_STRONG , BiometricManager.Authenticators.BIOMETRIC_WEAK , and BiometricManager.Authenticators.DEVICE_CREDENTIAL |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setConfirmationRequired (boolean requireConfirmation)
Optional: Sets a hint to the system for whether to require user confirmation after
authentication. For example, implicit modalities like face and iris are passive, meaning
they don't require an explicit user action to complete authentication. If set to true,
these modalities should require the user to take some action (e.g. press a button)
before AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult)
is
called. Defaults to true.
A typical use case for not requiring confirmation would be for low-risk transactions, such as re-authenticating a recently authenticated application. A typical use case for requiring confirmation would be for authorizing a purchase.
Note that this just passes a hint to the system, which the system may then ignore. For example, a value of false may be ignored if the user has disabled implicit authentication in Settings, or if it does not apply to a particular modality (e.g. fingerprint).
Parameters | |
---|---|
requireConfirmation |
boolean : true if explicit user confirmation should be required, or
false otherwise. |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setDescription (CharSequence description)
Optional: Sets a description that will be shown on the prompt.
Parameters | |
---|---|
description |
CharSequence : The description to display.
This value cannot be null . |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setDeviceCredentialAllowed (boolean allowed)
This method is deprecated.
Replaced by setAllowedAuthenticators(int)
.
Optional: If enabled, the user will be given the option to authenticate with their device
PIN, pattern, or password. Developers should first check BiometricManager#canAuthenticate(int)
for Authenticators#DEVICE_CREDENTIAL
before enabling. If the device is not secured with a credential,
AuthenticationCallback#onAuthenticationError(int, CharSequence)
will be invoked
with BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL
. Defaults to false.
Note that enabling this option replaces the negative button on the prompt with one
that allows the user to authenticate with their device credential, making it an error to
call setNegativeButton(java.lang.CharSequence, java.util.concurrent.Executor, android.content.DialogInterface.OnClickListener)
.
Parameters | |
---|---|
allowed |
boolean : true if the prompt should fall back to asking for the user's device
credential (PIN/pattern/password), or false otherwise. |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setNegativeButton (CharSequence text, Executor executor, DialogInterface.OnClickListener listener)
Required: Sets the text, executor, and click listener for the negative button on the prompt. This is typically a cancel button, but may be also used to show an alternative method for authentication, such as a screen that asks for a backup password.
Note that this setting is not required, and in fact is explicitly disallowed, if
device credential authentication is enabled via setAllowedAuthenticators(int)
or
setDeviceCredentialAllowed(boolean)
.
Parameters | |
---|---|
text |
CharSequence : Text to be shown on the negative button for the prompt.
This value cannot be null . |
executor |
Executor : Executor that will be used to run the on click callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
To dispatch events through a shared thread pool, you can use
AsyncTask#THREAD_POOL_EXECUTOR . |
listener |
DialogInterface.OnClickListener : Listener containing a callback to be run when the button is pressed.
This value cannot be null . |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setSubtitle (CharSequence subtitle)
Optional: Sets a subtitle that will be shown on the prompt.
Parameters | |
---|---|
subtitle |
CharSequence : The subtitle to display.
This value cannot be null . |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |
public BiometricPrompt.Builder setTitle (CharSequence title)
Required: Sets the title that will be shown on the prompt.
Parameters | |
---|---|
title |
CharSequence : The title to display.
This value cannot be null . |
Returns | |
---|---|
BiometricPrompt.Builder |
This builder.
This value cannot be null . |