# PendingIntentHandler

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/provider/PendingIntentHandler.kt+class:androidx.credentials.provider.PendingIntentHandler) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***


```
public final class PendingIntentHandler
```

<br />

*** ** * ** ***

PendingIntentHandler to be used by credential providers to extract requests from a given intent, or to set back a response or an exception to a given intent while dealing with activities invoked by pending intents set on a `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry` for the create flow, or on a `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`, `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction`, `https://developer.android.com/reference/androidx/credentials/provider/Action`, or a `https://developer.android.com/reference/androidx/credentials/provider/RemoteEntry` set for a get flow.

When user selects one of the entries mentioned above, the credential provider's corresponding activity is invoked. The intent associated with this activity must be extracted and passed into the utils in this class to extract the required requests.

When user interaction is complete, credential providers must set the activity result by calling `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` by setting an appropriate result code and data of type `https://developer.android.com/reference/android/content/Intent.html`. This data should also be prepared by using the utils in this class to populate the required response/exception.

See extension functions for `https://developer.android.com/reference/android/content/Intent.html` in IntentHandlerConverters.kt to help test intents that are set on pending intents in different entry classes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#PendingIntentHandler()()` |

| ### Public methods |
|---|---|
| `static final https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialRequest` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#retrieveBeginGetCredentialRequest(android.content.Intent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent)` Extracts the `https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system when the user selects an `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction`. |
| `static final https://developer.android.com/reference/androidx/credentials/provider/ProviderCreateCredentialRequest` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#retrieveProviderCreateCredentialRequest(android.content.Intent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent)` Extracts the `https://developer.android.com/reference/androidx/credentials/provider/ProviderCreateCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system. |
| `static final https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#retrieveProviderGetCredentialRequest(android.content.Intent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent)` Extracts the `https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system, when the user selects a `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`. |
| `static final void` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse response )` Sets the `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.html` on the intent passed in. |
| `static final void` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setCreateCredentialException(android.content.Intent,androidx.credentials.exceptions.CreateCredentialException)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException exception )` Sets the `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException` if an error is encountered during the final phase of the create credential flow. |
| `static final void` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setCreateCredentialResponse(android.content.Intent,androidx.credentials.CreateCredentialResponse)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse response )` Sets the `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse` on the intent passed in. |
| `static final void` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/GetCredentialException exception )` Sets the `https://developer.android.com/reference/androidx/credentials/exceptions/GetCredentialException` if an error is encountered during the final phase of the get credential flow. |
| `static final void` | `[setGetCredentialResponse](https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialResponse response )` **This method is deprecated.** Use setGetCredentialResponse(Intent, GetCredentialResponse, ProviderGetCredentialRequest) instead. |
| `static final void` | `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialResponse response, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest request )` Sets the `https://developer.android.com/reference/android/credentials/GetCredentialResponse.html` on the intent passed in. |

## Public constructors

### PendingIntentHandler

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

```
public PendingIntentHandler()
```

## Public methods

### retrieveBeginGetCredentialRequest

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

```
public static final BeginGetCredentialRequest retrieveBeginGetCredentialRequest(@NonNull Intent intent)
```

Extracts the `https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system when the user selects an `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent associated with the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#retrieveBeginGetCredentialRequest(android.content.Intent)` is null |

### retrieveProviderCreateCredentialRequest

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

```
public static final ProviderCreateCredentialRequest retrieveProviderCreateCredentialRequest(@NonNull Intent intent)
```

Extracts the `https://developer.android.com/reference/androidx/credentials/provider/ProviderCreateCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent associated with the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#retrieveProviderCreateCredentialRequest(android.content.Intent)` is null |

### retrieveProviderGetCredentialRequest

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

```
public static final ProviderGetCredentialRequest retrieveProviderGetCredentialRequest(@NonNull Intent intent)
```

Extracts the `https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest` from the provider's `https://developer.android.com/reference/android/app/PendingIntent.html` invoked by the Android system, when the user selects a `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent associated with the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#retrieveProviderGetCredentialRequest(android.content.Intent)` is null |

### setBeginGetCredentialResponse

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

```
public static final void setBeginGetCredentialResponse(
    @NonNull Intent intent,
    @NonNull BeginGetCredentialResponse response
)
```

Sets the `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.html` on the intent passed in. This intent is then set as the data associated with the result of the activity invoked by the `https://developer.android.com/reference/android/app/PendingIntent.html`, set on an `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction`. The intent is set using the `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` method that takes in the intent, as well as a result code.

A credential provider must set the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK` if a valid response, or a valid exception is being set as part of the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`. Note that setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the account selection bottom sheet that displayed the original `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`, hence allowing the user to re-select.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse response` | the response to be set as an extra on the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)` is null |

### setCreateCredentialException

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

```
public static final void setCreateCredentialException(
    @NonNull Intent intent,
    @NonNull CreateCredentialException exception
)
```

Sets the `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException` if an error is encountered during the final phase of the create credential flow.

A credential provider service returns a list of `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry` as part of the `https://developer.android.com/reference/android/service/credentials/BeginCreateCredentialResponse.html` to the query phase of the get-credential flow.

If the user selects one of these entries, the corresponding `https://developer.android.com/reference/android/app/PendingIntent.html` is fired and the provider's activity is invoked. If there is an error encountered during the lifetime of that activity, the provider must use this API to set an exception before finishing the activity.

The intent is set using the `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` method that takes in the intent, as well as a result code. A credential provider must set the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK` if a valid credential, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`.

Note that setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the account selection bottom sheet that displayed the original `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry`, hence allowing the user to re-select.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException exception` | the exception to be set as an extra to the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialException(android.content.Intent,androidx.credentials.exceptions.CreateCredentialException)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialException(android.content.Intent,androidx.credentials.exceptions.CreateCredentialException)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialException(android.content.Intent,androidx.credentials.exceptions.CreateCredentialException)` is null |

### setCreateCredentialResponse

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

```
public static final void setCreateCredentialResponse(
    @NonNull Intent intent,
    @NonNull CreateCredentialResponse response
)
```

Sets the `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse` on the intent passed in. This intent is then set as the data associated with the result of the activity invoked by the `https://developer.android.com/reference/android/app/PendingIntent.html` set on a `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry`. The intent is set using the `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` method that takes in the intent, as well as a result code.

A credential provider must set the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK` if a valid response, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`. Note that setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the account selection bottom sheet that displayed the original `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`, hence allowing the user to re-select.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse response` | the response to be set as an extra on the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialResponse(android.content.Intent,androidx.credentials.CreateCredentialResponse)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialResponse(android.content.Intent,androidx.credentials.CreateCredentialResponse)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setCreateCredentialResponse(android.content.Intent,androidx.credentials.CreateCredentialResponse)` is null |

### setGetCredentialException

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

```
public static final void setGetCredentialException(
    @NonNull Intent intent,
    @NonNull GetCredentialException exception
)
```

Sets the `https://developer.android.com/reference/androidx/credentials/exceptions/GetCredentialException` if an error is encountered during the final phase of the get credential flow.

A credential provider service returns a list of `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html` as part of the `https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse` to the query phase of the get-credential flow. If the user selects one of these entries, the corresponding `https://developer.android.com/reference/android/app/PendingIntent.html` is fired and the provider's activity is invoked. If there is an error encountered during the lifetime of that activity, the provider must use this API to set an exception on the given intent before finishing the activity in question.

The intent is set using the `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` method that takes in the intent, as well as a result code. A credential provider must set the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK` if a valid credential, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`.

Note that setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the account selection bottom sheet that displayed the original `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`, hence allowing the user to re-select.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/GetCredentialException exception` | the exception to be set as an extra to the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)` is null |

### setGetCredentialResponse

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0) Deprecated in [1.7.0-alpha03](https://developer.android.com/jetpack/androidx/releases/credentials#1.7.0-alpha03)

```
public static final void [setGetCredentialResponse](https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse))(
    @NonNull Intent intent,
    @NonNull GetCredentialResponse response
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use setGetCredentialResponse(Intent, GetCredentialResponse, ProviderGetCredentialRequest) instead, use this instead:
>
> ```
> setGetCredentialResponse(intent, response, request)
> ```

Sets the `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse` on the intent passed in.

This API is deprecated and will be removed in Credentials 2.0. Use setGetCredentialResponse(Intent, GetCredentialResponse, ProviderGetCredentialRequest) instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialResponse response` | the response to be set as an extra on the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse)` is null |

### setGetCredentialResponse

Added in [1.7.0-alpha03](https://developer.android.com/jetpack/androidx/releases/credentials#1.7.0-alpha03)

```
public static final void setGetCredentialResponse(
    @NonNull Intent intent,
    @NonNull GetCredentialResponse response,
    @NonNull ProviderGetCredentialRequest request
)
```

Sets the `https://developer.android.com/reference/android/credentials/GetCredentialResponse.html` on the intent passed in. This intent is then set as the data associated with the result of the activity invoked by the `https://developer.android.com/reference/android/app/PendingIntent.html`, set on a `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`. The intent is set using the `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` method that takes in the intent, as well as a result code.

A credential provider must set the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK` if a valid credential, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`. Note that setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the account selection bottom sheet that displayed the original `https://developer.android.com/reference/android/service/credentials/CredentialEntry.html`, hence allowing the user to re-select.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | the intent to be set on the result of the `https://developer.android.com/reference/android/app/Activity.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialResponse response` | the response to be set as an extra on the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest request` | the `https://developer.android.com/reference/androidx/credentials/provider/ProviderGetCredentialRequest` that this `response` fulfills, retrieved through the `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#retrieveProviderGetCredentialRequest(android.content.Intent)` method |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)`, `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)`, or `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler.Companion#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)` is null |