Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# AuthenticationCallback

*** ** * ** ***

```
abstract class AuthenticationCallback
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.hardware.biometrics.EmbeddedBiometricPrompt.AuthenticationCallback](https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#) |

Callback structure provided to `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt#startAuthenticationSession(android.os.CancellationSignal,%20kotlin.Int,%20java.util.concurrent.Executor,%20android.hardware.biometrics.EmbeddedBiometricPrompt.AuthenticationCallback)`. Users must provide an implementation of this for listening to authentication events.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#AuthenticationCallback()()` <br /> |

| Public methods ||
|---|---|
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationError(kotlin.Int,%20kotlin.CharSequence)(errorCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, errString: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)` Called when an unrecoverable error has been encountered and the operation is complete. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationFailed()()` Called when a biometric is valid but not recognized. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationHelp(kotlin.Int,%20kotlin.CharSequence)(helpCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, helpString: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)` Called when a recoverable error has been encountered during authentication. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationPaused()()` Called when the authentication session has been paused. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationResumed()()` Called when the authentication session has been resumed. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationSucceeded(android.hardware.biometrics.BiometricPrompt.AuthenticationResult)(result: https://developer.android.com/reference/kotlin/android/hardware/biometrics/BiometricPrompt.AuthenticationResult)` Called when a biometric is recognized. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onBackPressed()()` Called when the user triggers a back gesture or back key press. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onSessionStarted(kotlin.Long)(sessionId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Called when the authentication session has started. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onTappedOutside()()` Called when the user taps outside the bounds of the prompt. |

## Public constructors

### AuthenticationCallback

```
AuthenticationCallback()
```

## Public methods

### onAuthenticationError

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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, `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onBackPressed()` is called instead of this method.

| Parameters ||
|---|---|
| `errorCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): An integer from `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#` identifying the error message |
| `errString` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): A human-readable error string that can be shown on an UI. This value cannot be `null`. |

### onAuthenticationFailed

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onAuthenticationFailed(): Unit
```

Called when a biometric is valid but not recognized.

### onAuthenticationHelp

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): An integer from `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#` or `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#` corresponding to a known error message. |
| `helpString` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): A human-readable string that can be shown on an UI. This value cannot be `null`. |

### onAuthenticationPaused

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onAuthenticationPaused(): Unit
```

Called when the authentication session has been paused.

### onAuthenticationResumed

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onAuthenticationResumed(): Unit
```

Called when the authentication session has been resumed.

### onAuthenticationSucceeded

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

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

Called when a biometric is recognized.

| Parameters ||
|---|---|
| `result` | [BiometricPrompt.AuthenticationResult](https://developer.android.com/reference/kotlin/android/hardware/biometrics/BiometricPrompt.AuthenticationResult): An object containing authentication-related data. This value cannot be `null`. |

### onBackPressed

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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 `https://developer.android.com/reference/kotlin/android/hardware/biometrics/BiometricPrompt`, this callback is invoked directly instead of `https://developer.android.com/reference/kotlin/android/hardware/biometrics/EmbeddedBiometricPrompt.AuthenticationCallback#onAuthenticationError(kotlin.Int,%20kotlin.CharSequence)` with `https://developer.android.com/reference/kotlin/android/hardware/biometrics/BiometricPrompt#BIOMETRIC_ERROR_USER_CANCELED:kotlin.Int`.

### onSessionStarted

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onSessionStarted(sessionId: Long): Unit
```

Called when the authentication session has started.

| Parameters ||
|---|---|
| `sessionId` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The session id for this authentication operation. |

### onTappedOutside

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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 `https://developer.android.com/reference/kotlin/android/os/CancellationSignal.html#` provided when starting the session.