# BeginGetCredentialResponse.Builder

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

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                   ||
| ↳ | [android.service.credentials.BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) |

Builds an instance of [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse).

## Summary

|                                                               Public constructors                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                   ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [addAction](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#addAction(android.service.credentials.Action))`(`action:` `[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)`)` Adds an [Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action) to the list of actions to be displayed on the UI.                                                                                    |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [addAuthenticationAction](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#addAuthenticationAction(android.service.credentials.Action))`(`authenticationAction:` `[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)`)` Add an authentication entry to be shown on the UI.                                                                                                                                             |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [addCredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#addCredentialEntry(android.service.credentials.CredentialEntry))`(`credentialEntry:` `[CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry)`)` Adds a [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry) to the list of entries to be displayed on the UI.             |
| [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse)                  | [build](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#build())`()` Builds a [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) instance.                                                                                                                                                                                                                                    |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [setActions](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#setActions(kotlin.collections.MutableList))`(`actions:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)!>`)` Sets the list of actions to be displayed on the UI.                                                                             |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [setAuthenticationActions](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#setAuthenticationActions(kotlin.collections.MutableList))`(`authenticationActions:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)!>`)` Sets the list of authentication entries to be displayed on the account selector UI.   |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [setCredentialEntries](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#setCredentialEntries(kotlin.collections.MutableList))`(`credentialEntries:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry)!>`)` Sets the list of credential entries to be displayed on the account selector UI. |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | [setRemoteCredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#setRemoteCredentialEntry(android.service.credentials.RemoteEntry))`(`remoteCredentialEntry:` `[RemoteEntry](https://developer.android.com/reference/kotlin/android/service/credentials/RemoteEntry)?`)` Sets a remote credential entry to be shown on the UI.                                                                                                                       |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### addAction

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

```
fun addAction(action: Action): BeginGetCredentialResponse.Builder
```

Adds an [Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action) to the list of actions to be displayed on the UI.

An `action` must be used for independent user actions, such as opening the app, intenting directly into a certain app activity etc. The `pendingIntent` set with the `action` must invoke the corresponding activity.

|                                                             Parameters                                                              ||
|----------|---------------------------------------------------------------------------------------------------------------------------|
| `action` | [Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action): This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                       Exceptions                       ||
|----------------------------------|----------------------|
| `java.lang.NullPointerException` | If `action` is null. |

### addAuthenticationAction

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

```
fun addAuthenticationAction(authenticationAction: Action): BeginGetCredentialResponse.Builder
```

Add an authentication entry to be shown on the UI. Providers must set this entry if the corresponding account is locked and no underlying credentials can be returned.

When the user selects this `authenticationAction`, the system invokes the corresponding `pendingIntent`. Once the authentication action activity is launched, and the user is authenticated, providers should create another response with [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) using this time adding the unlocked credentials in the form of [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry)'s.

The new response object must be set on the authentication activity's result. The result code should be set to [android.app.Activity#RESULT_OK](https://developer.android.com/reference/kotlin/android/app/Activity.html#RESULT_OK:kotlin.Int) and the [CredentialProviderService.EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialProviderService#EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE:kotlin.String) extra should be set with the new fully populated [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) object.

|                                                                    Parameters                                                                     ||
|------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `authenticationAction` | [Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action): This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                              Exceptions                              ||
|----------------------------------|------------------------------------|
| `java.lang.NullPointerException` | If `authenticationAction` is null. |

### addCredentialEntry

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

```
fun addCredentialEntry(credentialEntry: CredentialEntry): BeginGetCredentialResponse.Builder
```

Adds a [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry) to the list of entries to be displayed on the UI.

|                                                                           Parameters                                                                           ||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `credentialEntry` | [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry): This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                             Exceptions                              ||
|----------------------------------|-----------------------------------|
| `java.lang.NullPointerException` | If the `credentialEntry` is null. |

### build

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

```
fun build(): BeginGetCredentialResponse
```

Builds a [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) instance.

|                                                                              Return                                                                               ||
|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) | This value cannot be `null`. |

### setActions

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

```
fun setActions(actions: MutableList<Action!>): BeginGetCredentialResponse.Builder
```

Sets the list of actions to be displayed on the UI.

|                                                                                                                    Parameters                                                                                                                    ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `actions` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)!\>: This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                                       Exceptions                                        ||
|----------------------------------|-------------------------------------------------------|
| `java.lang.NullPointerException` | If `actions` is null, or any of its elements is null. |

### setAuthenticationActions

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

```
fun setAuthenticationActions(authenticationActions: MutableList<Action!>): BeginGetCredentialResponse.Builder
```

Sets the list of authentication entries to be displayed on the account selector UI.

|                                                                                                                           Parameters                                                                                                                           ||
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `authenticationActions` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Action](https://developer.android.com/reference/kotlin/android/service/credentials/Action)!\>: This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                                              Exceptions                                               ||
|----------------------------------|---------------------------------------------------------------------|
| `java.lang.NullPointerException` | If `authenticationEntries` is null, or any of its elements is null. |

### setCredentialEntries

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

```
fun setCredentialEntries(credentialEntries: MutableList<CredentialEntry!>): BeginGetCredentialResponse.Builder
```

Sets the list of credential entries to be displayed on the account selector UI.

|                                                                                                                                  Parameters                                                                                                                                  ||
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `credentialEntries` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry)!\>: This value cannot be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |

|                                            Exceptions                                             ||
|----------------------------------|-----------------------------------------------------------------|
| `java.lang.NullPointerException` | If `credentialEntries` is null, or any of its elements is null. |

### setRemoteCredentialEntry

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

```
fun setRemoteCredentialEntry(remoteCredentialEntry: RemoteEntry?): BeginGetCredentialResponse.Builder
```

Sets a remote credential entry to be shown on the UI. Provider must set this if they wish to get the credential from a different device.

When constructing the [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry) object, the `pendingIntent` must be set such that it leads to an activity that can provide UI to fulfill the request on a remote device. When user selects this `remoteCredentialEntry`, the system will invoke the `pendingIntent` set on the [CredentialEntry](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialEntry).

Once the remote credential flow is complete, the [android.app.Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#) result should be set to [android.app.Activity#RESULT_OK](https://developer.android.com/reference/kotlin/android/app/Activity.html#RESULT_OK:kotlin.Int) and an extra with the [CredentialProviderService.EXTRA_GET_CREDENTIAL_RESPONSE](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialProviderService#EXTRA_GET_CREDENTIAL_RESPONSE:kotlin.String) key should be populated with a [android.credentials.Credential](https://developer.android.com/reference/kotlin/android/credentials/Credential.html#) object.

Note that as a provider service you will only be able to set a remote entry if : - Provider service possesses the [Manifest.permission.PROVIDE_REMOTE_CREDENTIALS](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#PROVIDE_REMOTE_CREDENTIALS:kotlin.String) permission. - Provider service is configured as the provider that can provide remote entries. If the above conditions are not met, setting back [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse) on the callback from [CredentialProviderService.onBeginGetCredential](https://developer.android.com/reference/kotlin/android/service/credentials/CredentialProviderService#onBeginGetCredential(android.service.credentials.BeginGetCredentialRequest,%20android.os.CancellationSignal,%20android.os.OutcomeReceiver)) will throw a [SecurityException](https://developer.android.com/reference/kotlin/java/lang/SecurityException.html#).   
Requires [android.Manifest.permission#PROVIDE_REMOTE_CREDENTIALS](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#PROVIDE_REMOTE_CREDENTIALS:kotlin.String)

|                                                                         Parameters                                                                         ||
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `remoteCredentialEntry` | [RemoteEntry](https://developer.android.com/reference/kotlin/android/service/credentials/RemoteEntry)?: This value may be `null`. |

|                                                                                       Return                                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/android/service/credentials/BeginGetCredentialResponse.Builder#) | This value cannot be `null`. |