EmbeddedBiometricPrompt
class EmbeddedBiometricPrompt
| kotlin.Any | |
| ↳ | android.hardware.biometrics.EmbeddedBiometricPrompt |
The embedded version of BiometricPrompt that allows client apps to pass in content to display above the biometric prompt as a connected sheet.
Summary
| Nested classes | |
|---|---|
| abstract |
Callback structure provided to |
|
A builder for the embedded version of BiometricPrompt that collects arguments to be shown on the system-provided biometric dialog. |
|
| abstract |
A factory that produces the custom embedded content view for the biometric prompt. |
| Constants | |
|---|---|
| static Int |
The prompt should be collapsed and display in the deferred/paused state. |
| static Int |
Start authentication immediately with the full prompt displayed. |
| static Int |
Start authentication immediately unless the embedded content height exceeds the maximum allowed dimensions. |
| Public methods | |
|---|---|
| Int |
Gets the type(s) of authenticators that may be invoked by the prompt. |
| EmbeddedBiometricPrompt.AuthenticationCallback? |
Gets the authentication callback used for the prompt. |
| Executor? |
Gets the executor used for the authentication callback. |
| Int |
Gets the authentication purpose for the prompt. |
| PromptContentView? |
Gets the content view, as set by |
| CharSequence? |
Gets the description, as set by |
| EmbeddedBiometricPrompt.EmbeddedContentFactory |
Gets the factory that will create the content to display above the biometric prompt as a connected sheet. |
| Long |
Returns the existing auth session id for BiometricPrompt. |
| MutableList<FallbackOption!> |
Gets the fallback options for the prompt. |
| Bitmap? |
Gets the logo bitmap, as set by |
| String? |
Gets the logo description, as set by |
| Int |
Gets the drawable resource of the logo, as set by |
| DialogInterface.OnClickListener? |
Gets the negative button listener, as set by |
| Executor? |
Gets the executor used for the negative button listener, as set by |
| CharSequence? |
Gets the negative button text, as set by |
| Int |
Gets the ending target layout translation offset in pixels (px) for the disappear (exit) animation. |
| Int |
Gets the starting layout translation offset in pixels (px) for the appear (entry) animation. |
| BiometricPromptStyleSpec? |
Returns a |
| CharSequence? |
Gets the subtitle, as set by |
| CharSequence? |
getTitle()Gets the title, as set by |
| Boolean |
Determines if explicit user confirmation is required by the prompt. |
| Unit |
Pauses biometric authentication and collapses the biometric prompt to the delayed state, displaying a button in its place. |
| Unit |
Activates biometric authentication and starts the biometric sensor scanning if delayed authentication was configured. |
| Unit |
setNextTranslationOffset(offset: Int)Sets the ending target layout translation offset in pixels (px) for the disappear (exit) animation. |
| Unit |
startAuthenticationSession(cancel: CancellationSignal, startMode: Int, executor: Executor, callback: EmbeddedBiometricPrompt.AuthenticationCallback)Starts an authentication session for embedded BiometricPrompt. |
Constants
START_MODE_DEFERRED
static val START_MODE_DEFERRED: Int
The prompt should be collapsed and display in the deferred/paused state. A shorter bottom sheet with a down arrow button is shown in place of the full prompt, and biometric sensors are not activated. Apps can call resumeAuthentication() when ready to expand the bottom sheet to the full prompt and activate biometric sensors to begin authenticating.
Value: 2START_MODE_IMMEDIATE
static val START_MODE_IMMEDIATE: Int
Start authentication immediately with the full prompt displayed.
Value: 0START_MODE_IMMEDIATE_UNLESS_OCCLUDED
static val START_MODE_IMMEDIATE_UNLESS_OCCLUDED: Int
Start authentication immediately unless the embedded content height exceeds the maximum allowed dimensions. If authentication is started and the provided embedded content exceeds the maximum available space, the prompt displays in the deferred/paused state, where it shows a shorter bottom sheet with a down arrow button in place of the full prompt, and biometric sensors are not activated. Apps can listen for AuthenticationCallback.onAuthenticationPaused in this case, and respond by calling resumeAuthentication() when ready to expand the bottom sheet to the full prompt and activate biometric sensors to begin authenticating.
Value: 1Public methods
getAllowedAuthenticators
fun getAllowedAuthenticators(): Int
Gets the type(s) of authenticators that may be invoked by the prompt.
| Return | |
|---|---|
Int |
A bit field representing the type(s) of authenticators that may be invoked by the prompt. |
getAuthenticationCallback
fun getAuthenticationCallback(): EmbeddedBiometricPrompt.AuthenticationCallback?
Gets the authentication callback used for the prompt.
| Return | |
|---|---|
EmbeddedBiometricPrompt.AuthenticationCallback? |
The authentication callback used for the prompt, or null if not set. |
getAuthenticationExecutor
fun getAuthenticationExecutor(): Executor?
Gets the executor used for the authentication callback.
| Return | |
|---|---|
Executor? |
The executor used for the authentication callback, or null if not set. |
getAuthenticationPurpose
fun getAuthenticationPurpose(): Int
Gets the authentication purpose for the prompt.
| Return | |
|---|---|
Int |
The authentication purpose. Value is one of the following: |
getContentView
fun getContentView(): PromptContentView?
Gets the content view, as set by Builder.setContentView(PromptContentView). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Return | |
|---|---|
PromptContentView? |
The content view for the prompt, or null if the prompt has no content view. |
getDescription
fun getDescription(): CharSequence?
Gets the description, as set by Builder.setDescription(CharSequence). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Return | |
|---|---|
CharSequence? |
The description for the prompt, or null if the prompt has no description. |
getEmbeddedContentFactory
fun getEmbeddedContentFactory(): EmbeddedBiometricPrompt.EmbeddedContentFactory
Gets the factory that will create the content to display above the biometric prompt as a connected sheet.
| Return | |
|---|---|
EmbeddedBiometricPrompt.EmbeddedContentFactory |
The factory used to create the content view. This value cannot be null. |
getExistingAuthSessionId
fun getExistingAuthSessionId(): Long
Returns the existing auth session id for BiometricPrompt.
| Return | |
|---|---|
Long |
The existing auth session id, or BiometricConstants.BIOMETRIC_REQUEST_ID_UNSET if none has been set. |
getFallbackOptions
fun getFallbackOptions(): MutableList<FallbackOption!>
Gets the fallback options for the prompt.
| Return | |
|---|---|
MutableList<FallbackOption!> |
The fallback options for the prompt. This value cannot be null. |
getLogoBitmap
fun getLogoBitmap(): Bitmap?
Gets the logo bitmap, as set by Builder.setLogoBitmap(Bitmap). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Requires android.Manifest.permission#SET_BIOMETRIC_DIALOG_ADVANCED
| Return | |
|---|---|
Bitmap? |
The logo bitmap of the prompt, or null if the prompt has no logo bitmap set. |
getLogoDescription
fun getLogoDescription(): String?
Gets the logo description, as set by Builder.setLogoDescription(String). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Requires android.Manifest.permission#SET_BIOMETRIC_DIALOG_ADVANCED
| Return | |
|---|---|
String? |
The logo description of the prompt, or null if the prompt has no logo description set. |
getLogoRes
fun getLogoRes(): Int
Gets the drawable resource of the logo, as set by Builder.setLogoRes(int). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
Requires android.Manifest.permission#SET_BIOMETRIC_DIALOG_ADVANCED
| Return | |
|---|---|
Int |
The drawable resource of the logo, or 0 if the prompt has no logo resource set. |
getNegativeButton
fun getNegativeButton(): DialogInterface.OnClickListener?
Gets the negative button listener, as set by Builder.setNegativeButton(CharSequence,Executor,DialogInterface.OnClickListener).
| Return | |
|---|---|
DialogInterface.OnClickListener? |
The negative button listener, or null if not set. |
getNegativeButtonExecutor
fun getNegativeButtonExecutor(): Executor?
Gets the executor used for the negative button listener, as set by Builder.setNegativeButton(CharSequence,Executor,DialogInterface.OnClickListener).
| Return | |
|---|---|
Executor? |
The executor used for the negative button listener, or null if not set. |
getNegativeButtonText
fun getNegativeButtonText(): CharSequence?
Gets the negative button text, as set by Builder.setNegativeButton(CharSequence,Executor,DialogInterface.OnClickListener).
| Return | |
|---|---|
CharSequence? |
The negative button text, or null if not set. |
getNextTranslationOffset
fun getNextTranslationOffset(): Int
Gets the ending target layout translation offset in pixels (px) for the disappear (exit) animation.
In portrait mode, this target offset is applied vertically along the Y-axis.
In landscape mode, this target offset is applied horizontally along the X-axis.
| Return | |
|---|---|
Int |
The ending target translation offset in pixels (px). |
getPreviousTranslationOffset
fun getPreviousTranslationOffset(): Int
Gets the starting layout translation offset in pixels (px) for the appear (entry) animation.
In portrait mode, this offset is applied vertically along the Y-axis.
| Return | |
|---|---|
Int |
The starting translation offset in pixels (px), or -1 if the system default is used. |
getStyleSpec
fun getStyleSpec(): BiometricPromptStyleSpec?
Returns a BiometricPromptStyleSpec containing the style specifications of BiometricPrompt
| Return | |
|---|---|
BiometricPromptStyleSpec? |
the style specifications of BiometricPrompt. This value may be null. |
getSubtitle
fun getSubtitle(): CharSequence?
Gets the subtitle, as set by Builder.setSubtitle(CharSequence). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Return | |
|---|---|
CharSequence? |
The subtitle for the prompt, or null if the prompt has no subtitle. |
getTitle
fun getTitle(): CharSequence?
Gets the title, as set by Builder.setTitle(CharSequence). This is only applicable to the device credential fallback page (when the user is authenticating with PIN/pattern/password).
| Return | |
|---|---|
CharSequence? |
The title of the prompt, or null if not set. |
isConfirmationRequired
fun isConfirmationRequired(): Boolean
Determines if explicit user confirmation is required by the prompt.
| Return | |
|---|---|
Boolean |
true if explicit user confirmation is required, or false otherwise. |
pauseAuthentication
fun pauseAuthentication(): Unit
Pauses biometric authentication and collapses the biometric prompt to the delayed state, displaying a button in its place.
resumeAuthentication
fun resumeAuthentication(): Unit
Activates biometric authentication and starts the biometric sensor scanning if delayed authentication was configured. If authentication was started with START_MODE_IMMEDIATE_UNLESS_OCCLUDED and the embedded content exceeds the allowed dimensions, or authentication was started with START_MODE_DEFERRED, the prompt is initially hidden and in a paused state, instead displaying a downward arrow button. Calling this method transitions the layout to show the sensor and biometric prompt content, and activates the biometric sensor to actively start authenticating.
setNextTranslationOffset
fun setNextTranslationOffset(offset: Int): Unit
Sets the ending target layout translation offset in pixels (px) for the disappear (exit) animation.
When the prompt is dismissed, it animates from its resting position to this target layout offset.
In portrait mode, the target offset is applied vertically along the Y-axis.
In landscape mode, the target offset is applied horizontally along the X-axis.
| Parameters | |
|---|---|
offset |
Int: The target translation offset in pixels (px). |
startAuthenticationSession
fun startAuthenticationSession(
cancel: CancellationSignal,
startMode: Int,
executor: Executor,
callback: EmbeddedBiometricPrompt.AuthenticationCallback
): Unit
Starts an authentication session for embedded BiometricPrompt. This call warms up the biometric hardware, displays a system-provided dialog, and starts scanning for a biometric. Authentication starts when AuthenticationCallback.onSessionStarted(long) is called, terminates when AuthenticationCallback.onAuthenticationError(int,CharSequence) is called, when AuthenticationCallback.onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult) is called, or when the user dismisses the system-provided dialog. This operation can be canceled by using the provided cancel object. The application will receive authentication errors through AuthenticationCallback, and button events through the corresponding callback set in Builder.addFallbackOption(CharSequence,int,Executor,DialogInterface.OnClickListener).
| Parameters | |
|---|---|
cancel |
CancellationSignal: An object that can be used to cancel authentication. This value cannot be null. |
startMode |
Int: The mode determining when authentication starts (e.g. START_MODE_IMMEDIATE, START_MODE_IMMEDIATE_UNLESS_OCCLUDED, or START_MODE_DEFERRED). Value is one of the following: |
executor |
Executor: An executor to handle callback events. 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: An object to receive authentication events. This value cannot be null. |