AuthenticationCallback


abstract class AuthenticationCallback
kotlin.Any
   ↳ android.hardware.biometrics.EmbeddedBiometricPrompt.AuthenticationCallback

Callback structure provided to EmbeddedBiometricPrompt.startAuthenticationSession(CancellationSignal,int,Executor,AuthenticationCallback). Users must provide an implementation of this for listening to authentication events.

Summary

Public constructors

Public methods
open Unit
onAuthenticationError(errorCode: Int, errString: CharSequence)

Called when an unrecoverable error has been encountered and the operation is complete.

open Unit

Called when a biometric is valid but not recognized.

open Unit
onAuthenticationHelp(helpCode: Int, helpString: CharSequence)

Called when a recoverable error has been encountered during authentication.

open Unit

Called when the authentication session has been paused.

open Unit

Called when the authentication session has been resumed.

open Unit

Called when a biometric is recognized.

open Unit

Called when the user triggers a back gesture or back key press.

open Unit
onSessionStarted(sessionId: Long)

Called when the authentication session has started.

open Unit

Called when the user taps outside the bounds of the prompt.

Public constructors

AuthenticationCallback

AuthenticationCallback()

Public methods

onAuthenticationError

open fun onAuthenticationError(
    errorCode: Int,
    errString: CharSequence
): Unit

Called when an unrecoverable error has been encountered and the operation is complete. No further actions will be made on this object.

Note that when the user triggers a back gesture, onBackPressed() is called instead of this method.

Parameters
errorCode Int: An integer from BiometricConstants.Errors identifying the error message
errString CharSequence: A human-readable error string that can be shown on an UI.
This value cannot be null.

onAuthenticationFailed

open fun onAuthenticationFailed(): Unit

Called when a biometric is valid but not recognized.

onAuthenticationHelp

open fun onAuthenticationHelp(
    helpCode: Int,
    helpString: CharSequence
): Unit

Called when a recoverable error has been encountered during authentication. The help string is provided to give the user guidance for what went wrong, such as "Sensor dirty, please clean it."

Parameters
helpCode Int: An integer from BiometricFaceConstants.FaceAcquired or BiometricFingerprintConstants.FingerprintAcquired corresponding to a known error message.
helpString CharSequence: A human-readable string that can be shown on an UI.
This value cannot be null.

onAuthenticationPaused

open fun onAuthenticationPaused(): Unit

Called when the authentication session has been paused.

onAuthenticationResumed

open fun onAuthenticationResumed(): Unit

Called when the authentication session has been resumed.

onAuthenticationSucceeded

open fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult): Unit

Called when a biometric is recognized.

Parameters
result BiometricPrompt.AuthenticationResult: An object containing authentication-related data.
This value cannot be null.

onBackPressed

open fun onBackPressed(): Unit

Called when the user triggers a back gesture or back key press.

Note that when a back gesture is triggered, the prompt is automatically dismissed and the authentication session is terminated. Unlike standard BiometricPrompt, this callback is invoked directly instead of onAuthenticationError(int,CharSequence) with BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED.

onSessionStarted

open fun onSessionStarted(sessionId: Long): Unit

Called when the authentication session has started.

Parameters
sessionId Long: The session id for this authentication operation.

onTappedOutside

open fun onTappedOutside(): Unit

Called when the user taps outside the bounds of the prompt.

Note that calling this method does not automatically dismiss the prompt or terminate the authentication session. If you wish to terminate authentication, you must explicitly cancel using the android.os.CancellationSignal provided when starting the session.