# BiometricPrompt

Artifact: [androidx.biometric:biometric](https://developer.android.com/jetpack/androidx/releases/biometric) [View Source](https://cs.android.com/search?q=file:androidx/biometric/BiometricPrompt.java+class:androidx.biometric.BiometricPrompt) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

*** ** * ** ***


```
class BiometricPrompt
```

<br />

*** ** * ** ***

A class that manages a system-provided biometric prompt. On devices running Android 9.0 (API 28) and above, this will show a system-provided authentication prompt, using one of the device's supported biometric modalities (fingerprint, iris, face, etc) with Class 2 or Class 3 strength. Prior to Android 9.0, this will instead show a custom fingerprint authentication dialog. The prompt will persist across configuration changes unless explicitly canceled. For security reasons, the prompt will be dismissed when the client application is no longer in the foreground.

To persist authentication across configuration changes, developers should (re)create the prompt every time the activity/fragment is created. Instantiating the prompt with a new callback early in the fragment/activity lifecycle (e.g. in `onCreate()`) will allow the ongoing authentication session's callbacks to be received by the new fragment/activity instance. Note that `cancelAuthentication()` should not be called, and `authenticate()` does not need to be invoked during activity/fragment creation.

Note that if multiple instances of `BiometricPrompt` are created within a single Fragment or Activity, only the callback registered with the last created instance will be saved and receive authentication results. This behavior can lead to unexpected results if multiple independent biometric authentication flows are attempted within the same Fragment or Activity. It is highly recommended to avoid creating multiple BiometricPrompt instances in this scenario.

## Summary

| ### Nested types |
|---|
| `abstract class https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` A collection of methods that may be invoked by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt` during authentication. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` A container for data passed to `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback#onAuthenticationSucceeded(androidx.biometric.BiometricPrompt.AuthenticationResult)` when the user has successfully authenticated. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.CryptoObject` A wrapper class for the crypto objects supported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo` A set of configurable options for how the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt` should appear and behave. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo.Builder` A builder used to set individual options for the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo` class. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#AUTHENTICATION_RESULT_TYPE_BIOMETRIC() = 2` Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated by presenting some form of biometric (e.g. fingerprint or face). |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL() = 1` Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated by entering their device PIN, pattern, or password. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#AUTHENTICATION_RESULT_TYPE_UNKNOWN() = -1` Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated via an unknown method. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_CANCELED() = 5` The operation was canceled because the biometric sensor is unavailable. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON() = 22` The user pressed the more options button on `https://developer.android.com/reference/kotlin/androidx/biometric/PromptContentViewWithMoreOptionsButton` set by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setContentView(androidx.biometric.PromptContentView)` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_HW_NOT_PRESENT() = 12` The device does not have the required authentication hardware. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_HW_UNAVAILABLE() = 1` The hardware is unavailable. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_IDENTITY_CHECK_NOT_ACTIVE() = 20` Identity Check is currently not active. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_LOCKOUT() = 7` The operation was canceled because the API is locked out due to too many attempts. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_LOCKOUT_PERMANENT() = 9` The operation was canceled because `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricConstants#ERROR_LOCKOUT()` occurred too many times. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_NEGATIVE_BUTTON() = 13` Indicates that the user pressed the negative button. \*\*Note:\*\* This constant is not used for results of type \[AuthenticationResult.Error\] in the new API. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_NO_BIOMETRICS() = 11` The user does not have any biometrics enrolled. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_NO_DEVICE_CREDENTIAL() = 14` The device does not have pin, pattern, or password set up. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_NO_SPACE() = 4` The operation can't be completed because there is not enough device storage remaining. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_SECURITY_UPDATE_REQUIRED() = 15` A security vulnerability has been discovered with one or more hardware sensors. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_TIMEOUT() = 3` The current operation has been running too long and has timed out. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_UNABLE_TO_PROCESS() = 2` The sensor was unable to process the current image. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_USER_CANCELED() = 10` The user canceled the operation. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#ERROR_VENDOR() = 8` The operation failed due to a vendor-specific error. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,androidx.biometric.BiometricPrompt.AuthenticationCallback)( activity: https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity, callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback )` Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,androidx.biometric.BiometricPrompt.AuthenticationCallback)( fragment: https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment, callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback )` Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)( activity: https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback )` Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)( fragment: https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback )` Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#authenticate(androidx.biometric.BiometricPrompt.PromptInfo)(info: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo)` Shows the biometric prompt to the user. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#authenticate(androidx.biometric.BiometricPrompt.PromptInfo,androidx.biometric.BiometricPrompt.CryptoObject)( info: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo, crypto: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.CryptoObject )` Shows the biometric prompt to the user. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#cancelAuthentication()()` Cancels the ongoing authentication session and dismisses the prompt. |

## Constants

### AUTHENTICATION_RESULT_TYPE_BIOMETRIC

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
const val AUTHENTICATION_RESULT_TYPE_BIOMETRIC = 2: Int
```

Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated by presenting some form of biometric (e.g. fingerprint or face).

### AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
const val AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL = 1: Int
```

Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated by entering their device PIN, pattern, or password.

### AUTHENTICATION_RESULT_TYPE_UNKNOWN

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
const val AUTHENTICATION_RESULT_TYPE_UNKNOWN = -1: Int
```

Authentication type reported by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationResult` when the user authenticated via an unknown method.

This value may be returned on older Android versions due to partial incompatibility with a newer API. It does NOT necessarily imply that the user authenticated with a method other than those represented by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricConstants#AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL()` and `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricConstants#AUTHENTICATION_RESULT_TYPE_BIOMETRIC()`.

### ERROR_CANCELED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_CANCELED = 5: Int
```

The operation was canceled because the biometric sensor is unavailable. This may happen when the user is switched, the device is locked, or another pending operation prevents it.

### ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
const val ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON = 22: Int
```

The user pressed the more options button on `https://developer.android.com/reference/kotlin/androidx/biometric/PromptContentViewWithMoreOptionsButton` set by `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setContentView(androidx.biometric.PromptContentView)`

### ERROR_HW_NOT_PRESENT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_HW_NOT_PRESENT = 12: Int
```

The device does not have the required authentication hardware.

### ERROR_HW_UNAVAILABLE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_HW_UNAVAILABLE = 1: Int
```

The hardware is unavailable. Try again later.

### ERROR_IDENTITY_CHECK_NOT_ACTIVE

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
const val ERROR_IDENTITY_CHECK_NOT_ACTIVE = 20: Int
```

Identity Check is currently not active. This device either doesn't have this feature enabled, or it's not considered in a high-risk environment that requires extra security measures for accessing sensitive data.

### ERROR_LOCKOUT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_LOCKOUT = 7: Int
```

The operation was canceled because the API is locked out due to too many attempts. This occurs after 5 failed attempts, and lasts for 30 seconds.

### ERROR_LOCKOUT_PERMANENT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_LOCKOUT_PERMANENT = 9: Int
```

The operation was canceled because `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricConstants#ERROR_LOCKOUT()` occurred too many times. Biometric authentication is disabled until the user unlocks with their device credential (i.e. PIN, pattern, or password).

### ERROR_NEGATIVE_BUTTON

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_NEGATIVE_BUTTON = 13: Int
```

Indicates that the user pressed the negative button. \*\*Note:\*\* This constant is not used for results of type \[AuthenticationResult.Error\] in the new API. Instead, negative button clicks are delivered via \[AuthenticationResult.CustomFallbackSelected\].

### ERROR_NO_BIOMETRICS

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_NO_BIOMETRICS = 11: Int
```

The user does not have any biometrics enrolled.

### ERROR_NO_DEVICE_CREDENTIAL

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_NO_DEVICE_CREDENTIAL = 14: Int
```

The device does not have pin, pattern, or password set up.

### ERROR_NO_SPACE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_NO_SPACE = 4: Int
```

The operation can't be completed because there is not enough device storage remaining.

### ERROR_SECURITY_UPDATE_REQUIRED

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
const val ERROR_SECURITY_UPDATE_REQUIRED = 15: Int
```

A security vulnerability has been discovered with one or more hardware sensors. The affected sensor(s) are unavailable until a security update has addressed the issue.

### ERROR_TIMEOUT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_TIMEOUT = 3: Int
```

The current operation has been running too long and has timed out.

This is intended to prevent programs from waiting for the biometric sensor indefinitely. The timeout is platform and sensor-specific, but is generally on the order of \~30 seconds.

### ERROR_UNABLE_TO_PROCESS

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_UNABLE_TO_PROCESS = 2: Int
```

The sensor was unable to process the current image.

### ERROR_USER_CANCELED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_USER_CANCELED = 10: Int
```

The user canceled the operation.

Upon receiving this, applications should use alternate authentication, such as a password. The application should also provide the user a way of returning to biometric authentication, such as a button.

### ERROR_VENDOR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
const val ERROR_VENDOR = 8: Int
```

The operation failed due to a vendor-specific error.

This error code may be used by hardware vendors to extend this list to cover errors that don't fall under one of the other predefined categories. Vendors are responsible for providing the strings for these errors.

These messages are typically reserved for internal operations such as enrollment but may be used to express any error that is not otherwise covered. In this case, applications are expected to show the error message, but they are advised not to rely on the message ID, since this may vary by vendor and device.

## Public constructors

### BiometricPrompt

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
BiometricPrompt(
    activity: FragmentActivity,
    callback: BiometricPrompt.AuthenticationCallback
)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. The prompt can be shown to the user by calling `authenticate()` and persists across device configuration changes by default.

If authentication is in progress, calling this constructor to recreate the prompt will also update the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` for the current session. Thus, this method should be called by the client activity each time the configuration changes (e.g. in `onCreate()`).

| Parameters |
|---|---|
| `activity: https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity` | The activity of the client application that will host the prompt. |
| `callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` | The object that will receive and process authentication events. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |

### BiometricPrompt

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0)

```
BiometricPrompt(
    fragment: Fragment,
    callback: BiometricPrompt.AuthenticationCallback
)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. The prompt can be shown to the user by calling `authenticate()` and persists across device configuration changes by default.

If authentication is in progress, calling this constructor to recreate the prompt will also update the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` for the current session. Thus, this method should be called by the client fragment each time the configuration changes (e.g. in `onCreate()`).

| Parameters |
|---|---|
| `fragment: https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment` | The fragment of the client application that will host the prompt. |
| `callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` | The object that will receive and process authentication events. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |

### BiometricPrompt

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
BiometricPrompt(
    activity: FragmentActivity,
    executor: Executor,
    callback: BiometricPrompt.AuthenticationCallback
)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. The prompt can be shown to the user by calling `authenticate()` and persists across device configuration changes by default.

If authentication is in progress, calling this constructor to recreate the prompt will also update the `https://developer.android.com/reference/java/util/concurrent/Executor.html` and `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` for the current session. Thus, this method should be called by the client activity each time the configuration changes (e.g. in `onCreate()`).

| Parameters |
|---|---|
| `activity: https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity` | The activity of the client application that will host the prompt. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor that will be used to run `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` methods. |
| `callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` | The object that will receive and process authentication events. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |

### BiometricPrompt

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
BiometricPrompt(
    fragment: Fragment,
    executor: Executor,
    callback: BiometricPrompt.AuthenticationCallback
)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt`, which can be used to prompt the user to authenticate with a biometric such as fingerprint or face. The prompt can be shown to the user by calling `authenticate()` and persists across device configuration changes by default.

If authentication is in progress, calling this constructor to recreate the prompt will also update the `https://developer.android.com/reference/java/util/concurrent/Executor.html` and `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` for the current session. Thus, this method should be called by the client fragment each time the configuration changes (e.g. in `onCreate()`).

| Parameters |
|---|---|
| `fragment: https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment` | The fragment of the client application that will host the prompt. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor that will be used to run `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` methods. |
| `callback: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.AuthenticationCallback` | The object that will receive and process authentication events. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.Fragment,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,java.util.concurrent.Executor,androidx.biometric.BiometricPrompt.AuthenticationCallback)` |   |

## Public functions

### authenticate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
fun authenticate(info: BiometricPrompt.PromptInfo): Unit
```

Shows the biometric prompt to the user. The prompt survives lifecycle changes by default. To cancel authentication and dismiss the prompt, use `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#cancelAuthentication()`.

| Parameters |
|---|---|
| `info: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo` | An object describing the appearance and behavior of the prompt. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#authenticate(androidx.biometric.BiometricPrompt.PromptInfo,androidx.biometric.BiometricPrompt.CryptoObject)` |   |

### authenticate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
fun authenticate(
    info: BiometricPrompt.PromptInfo,
    crypto: BiometricPrompt.CryptoObject
): Unit
```

Shows the biometric prompt to the user. The prompt survives lifecycle changes by default. To cancel authentication and dismiss the prompt, use `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#cancelAuthentication()`.

Calling this method invokes crypto-based authentication, which is incompatible with **Class 2** (formerly **Weak** ) biometrics and (prior to Android 11) device credential. Therefore, it is an error for `info` to explicitly allow any of these authenticator types on an incompatible Android version.

| Parameters |
|---|---|
| `info: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo` | An object describing the appearance and behavior of the prompt. |
| `crypto: https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.CryptoObject` | A crypto object to be associated with this authentication. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If any of the allowed authenticator types specified by `info` do not support crypto-based authentication. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt#authenticate(androidx.biometric.BiometricPrompt.PromptInfo)` |   |
| `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setAllowedAuthenticators(int)` |   |

### cancelAuthentication

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
fun cancelAuthentication(): Unit
```

Cancels the ongoing authentication session and dismisses the prompt.

On versions prior to Android 10 (API 29), calling this method while the user is authenticating with their device credential will NOT work as expected. See `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setDeviceCredentialAllowed(boolean)` for more details.