EmbeddedBiometricPrompt.Builder
public
static
final
class
EmbeddedBiometricPrompt.Builder
extends Object
| java.lang.Object | |
| ↳ | android.hardware.biometrics.EmbeddedBiometricPrompt.Builder |
A builder for the embedded version of BiometricPrompt that collects arguments to be shown on the system-provided biometric dialog.
Summary
Public constructors | |
|---|---|
Builder(Context context)
Creates a builder for an embedded |
|
Public methods | |
|---|---|
EmbeddedBiometricPrompt.Builder
|
addFallbackOption(CharSequence text, int iconType, Executor executor, DialogInterface.OnClickListener listener)
Optional: Sets the text, icon, executor, and click listener for a fallback option. |
EmbeddedBiometricPrompt
|
build()
Creates an |
EmbeddedBiometricPrompt.Builder
|
setAllowedAuthenticators(int authenticators)
Optional: Specifies the type(s) of authenticators that may be invoked. |
EmbeddedBiometricPrompt.Builder
|
setAuthenticationCallback(Executor executor, EmbeddedBiometricPrompt.AuthenticationCallback callback)
Optional: Sets the authentication callback and executor. |
EmbeddedBiometricPrompt.Builder
|
setAuthenticationPurpose(int purpose)
Optional: Sets the authentication purpose for the prompt. |
EmbeddedBiometricPrompt.Builder
|
setConfirmationRequired(boolean requireConfirmation)
Optional: Sets a hint to the system for whether to require user confirmation after authentication. |
EmbeddedBiometricPrompt.Builder
|
setContentView(PromptContentView view)
Optional: Sets application customized content view that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setDescription(CharSequence description)
Optional: Sets a description that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setEmbeddedContentFactory(EmbeddedBiometricPrompt.EmbeddedContentFactory contentFactory)
Sets the factory that will create the content to display above the biometric prompt as a connected sheet. |
EmbeddedBiometricPrompt.Builder
|
setExistingAuthSessionId(long authSessionId)
Optional: Sets the id for an existing authentication session. |
EmbeddedBiometricPrompt.Builder
|
setLogoBitmap(Bitmap logoBitmap)
Optional: Sets the bitmap drawable of the logo that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setLogoDescription(String logoDescription)
Optional: Sets logo description text that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setLogoRes(int logoRes)
Optional: Sets the drawable resource of the logo that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setNegativeButton(CharSequence text, Executor executor, DialogInterface.OnClickListener listener)
Optional: Sets the text, executor, and click listener for the negative button on the prompt. |
EmbeddedBiometricPrompt.Builder
|
setNextTranslationOffset(int nextTranslationOffset)
Optional: Sets the ending target layout translation offset in pixels (px) for the disappear (exit) animation of the biometric prompt. |
EmbeddedBiometricPrompt.Builder
|
setPreviousTranslationOffset(int previousTranslationOffset)
Optional: Sets the starting layout translation offset in pixels (px) for the appear (entry) animation of the biometric prompt. |
EmbeddedBiometricPrompt.Builder
|
setSubtitle(CharSequence subtitle)
Optional: Sets a subtitle that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
EmbeddedBiometricPrompt.Builder
|
setTitle(CharSequence title)
Required: Sets the title that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password). |
Inherited methods | |
|---|---|
Public constructors
Builder
public Builder (Context context)
Creates a builder for an embedded BiometricPrompt dialog.
| Parameters | |
|---|---|
context |
Context: The Context that will be used to build the prompt.
This value cannot be null. |
Public methods
addFallbackOption
public EmbeddedBiometricPrompt.Builder addFallbackOption (CharSequence text, int iconType, Executor executor, DialogInterface.OnClickListener listener)
Optional: Sets the text, icon, executor, and click listener for a fallback option.
| Parameters | |
|---|---|
text |
CharSequence: The text to display for the fallback option.
This value cannot be null. |
iconType |
int: The icon to display for the fallback option.
Value is one of the following: |
executor |
Executor: The executor to use for the click listener.
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().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
listener |
DialogInterface.OnClickListener: The click listener to use for the fallback option.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
build
public EmbeddedBiometricPrompt build ()
Creates an EmbeddedBiometricPrompt.
| Returns | |
|---|---|
EmbeddedBiometricPrompt |
The created EmbeddedBiometricPrompt.
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if the factory to create embedded content is not provided. |
setAllowedAuthenticators
public EmbeddedBiometricPrompt.Builder setAllowedAuthenticators (int authenticators)
Optional: Specifies the type(s) of authenticators that may be invoked.
| Parameters | |
|---|---|
authenticators |
int: A bit field representing the type(s) of authenticators that may be
invoked by the prompt.
Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setAuthenticationCallback
public EmbeddedBiometricPrompt.Builder setAuthenticationCallback (Executor executor, EmbeddedBiometricPrompt.AuthenticationCallback callback)
Optional: Sets the authentication callback and executor.
| Parameters | |
|---|---|
executor |
Executor: The executor to use for the authentication 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().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
EmbeddedBiometricPrompt.AuthenticationCallback: The authentication callback.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setAuthenticationPurpose
public EmbeddedBiometricPrompt.Builder setAuthenticationPurpose (int purpose)
Optional: Sets the authentication purpose for the prompt.
Provides a hint to customize the BiometricPrompt appearance to clarify what
the user is authorizing. This is cosmetic only, can vary by device, and does not change
security guarantees (see setAllowedAuthenticators(int)).
For example, this may inform the user to click or tap "to pay" instead of "to authenticate".
| Parameters | |
|---|---|
purpose |
int: The authentication purpose to set.
Value is one of the following: |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setConfirmationRequired
public EmbeddedBiometricPrompt.Builder setConfirmationRequired (boolean requireConfirmation)
Optional: Sets a hint to the system for whether to require user confirmation after authentication.
| Parameters | |
|---|---|
requireConfirmation |
boolean: Whether to require user confirmation. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setContentView
public EmbeddedBiometricPrompt.Builder setContentView (PromptContentView view)
Optional: Sets application customized content view that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Note that the description set by Builder.setDescription(CharSequence) will be
overridden by Builder.setContentView(PromptContentView). The view provided to
Builder.setContentView(PromptContentView) will be used if both methods are
called.
| Parameters | |
|---|---|
view |
PromptContentView: The customized view information to display on the credential page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setDescription
public EmbeddedBiometricPrompt.Builder setDescription (CharSequence description)
Optional: Sets a description that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Note that the description set by Builder.setDescription(CharSequence) will be
overridden by Builder.setContentView(PromptContentView). The view provided to
Builder.setContentView(PromptContentView) will be used if both methods are
called.
| Parameters | |
|---|---|
description |
CharSequence: The description to display on the credential page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setEmbeddedContentFactory
public EmbeddedBiometricPrompt.Builder setEmbeddedContentFactory (EmbeddedBiometricPrompt.EmbeddedContentFactory contentFactory)
Sets the factory that will create the content to display above the biometric prompt as a connected sheet.
| Parameters | |
|---|---|
contentFactory |
EmbeddedBiometricPrompt.EmbeddedContentFactory: The factory to use to create the content view.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setExistingAuthSessionId
public EmbeddedBiometricPrompt.Builder setExistingAuthSessionId (long authSessionId)
Optional: Sets the id for an existing authentication session.
| Parameters | |
|---|---|
authSessionId |
long: The id for an existing authentication session. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setLogoBitmap
public EmbeddedBiometricPrompt.Builder setLogoBitmap (Bitmap logoBitmap)
Optional: Sets the bitmap drawable of the logo that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Note that using this method is not recommended in most scenarios because the calling
application's icon will be used by default. Setting the logo is intended for large
bundled applications that perform a wide range of functions and need to show distinct
icons for each function.
Requires Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED
| Parameters | |
|---|---|
logoBitmap |
Bitmap: A bitmap drawable of the logo that will be shown on the credential
page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setLogoDescription
public EmbeddedBiometricPrompt.Builder setLogoDescription (String logoDescription)
Optional: Sets logo description text that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Note that using this method is not recommended in most scenarios because the calling
application's name will be used by default. Setting the logo description is intended for
large bundled applications that perform a wide range of functions and need to show
distinct description for each function.
Requires Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED
| Parameters | |
|---|---|
logoDescription |
String: The logo description text that will be shown on the credential
page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setLogoRes
public EmbeddedBiometricPrompt.Builder setLogoRes (int logoRes)
Optional: Sets the drawable resource of the logo that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Note that using this method is not recommended in most scenarios because the calling
application's icon will be used by default. Setting the logo is intended for large
bundled applications that perform a wide range of functions and need to show distinct
icons for each function.
Requires Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED
| Parameters | |
|---|---|
logoRes |
int: A drawable resource of the logo that will be shown on the credential page. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setNegativeButton
public EmbeddedBiometricPrompt.Builder setNegativeButton (CharSequence text, Executor executor, DialogInterface.OnClickListener listener)
Optional: 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.
If not provided and no fallback is added through
addFallbackOption(CharSequence,int,Executor,DialogInterface.OnClickListener)
(API 36.1 and later),
the option to use device credential will be
shown as the negative button if allowed in setAllowedAuthenticators(int). If
credential is not allowed, "Cancel" will be shown as the negative button.
In API 36 and earlier, this setting is required. Note that this setting is not
required, and in fact is explicitly disallowed, if
device credential authentication is enabled via setAllowedAuthenticators(int).
To use credential authentication and
provide custom behavior, use
addFallbackOption(CharSequence,int,Executor,DialogInterface.OnClickListener)
| 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().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
listener |
DialogInterface.OnClickListener: Listener containing a callback to be run when the button is pressed.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setNextTranslationOffset
public EmbeddedBiometricPrompt.Builder setNextTranslationOffset (int nextTranslationOffset)
Optional: Sets the ending target layout translation offset in pixels (px) for the disappear (exit) animation of the biometric prompt.
When the prompt is dismissed, it animates from its resting position to this target layout offset.
In portrait mode, the offset is applied vertically along the Y-axis (vertical slide).
In landscape mode, the offset is applied horizontally along the X-axis (horizontal slide), relative to the display boundaries based on the current screen rotation (e.g. 90 or 270 degrees).
This absolute pixel value can be used to synchronize the exit of the prompt with the entry animation of a subsequent screen in the client application.
| Parameters | |
|---|---|
nextTranslationOffset |
int: The ending target translation offset in pixels (px). |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setPreviousTranslationOffset
public EmbeddedBiometricPrompt.Builder setPreviousTranslationOffset (int previousTranslationOffset)
Optional: Sets the starting layout translation offset in pixels (px) for the appear (entry) animation of the biometric prompt.
When the prompt is shown, its initial position is translated by this offset relative to its final resting position, and it animates to its final centered position (0 translation). If not set, or set to -1, a default system vertical translation is used.
In portrait mode, the offset is applied vertically along the Y-axis.
This absolute pixel value can be used to synchronize the entry of the prompt with the exit animation of a preceding screen in the client application.
| Parameters | |
|---|---|
previousTranslationOffset |
int: The starting translation offset in pixels (px). |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setSubtitle
public EmbeddedBiometricPrompt.Builder setSubtitle (CharSequence subtitle)
Optional: Sets a subtitle that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Parameters | |
|---|---|
subtitle |
CharSequence: The subtitle to display on the credential page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |
setTitle
public EmbeddedBiometricPrompt.Builder setTitle (CharSequence title)
Required: Sets the title that will be shown on the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Parameters | |
|---|---|
title |
CharSequence: The title to display on the credential page.
This value cannot be null. |
| Returns | |
|---|---|
EmbeddedBiometricPrompt.Builder |
This builder.
This value cannot be null. |