# PasswordCredentialEntry.Builder

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

*** ** * ** ***

<br />

```
public final class PasswordCredentialEntry.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry`

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#context()`, `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#username()`, `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#pendingIntent()`, or `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#beginGetPasswordOption()` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#username()` is empty |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#Builder(android.content.Context,kotlin.CharSequence,android.app.PendingIntent,androidx.credentials.provider.BeginGetPasswordOption)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html username, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/BeginGetPasswordOption beginGetPasswordOption )` constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#build()()` Builds an instance of `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setAffiliatedDomain(kotlin.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence.html affiliatedDomain)` Sets whether the entry should have an affiliated domain, a CharSequence representation of some larger entity that may be used to bind multiple entries together (e.g. app_one, and app_two may be bound by 'super_app' as the larger affiliation domain) without length limit, default null. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setAutoSelectAllowed(kotlin.Boolean)(boolean autoSelectAllowed)` Sets whether the entry should be auto-selected. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 35) https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setBiometricPromptData(androidx.credentials.provider.BiometricPromptData)(https://developer.android.com/reference/androidx/credentials/provider/BiometricPromptData biometricPromptData)` Sets the biometric prompt data to optionally utilize a credential manager flow that directly handles the biometric verification for you and gives you the response; set to null by default, indicating the default behavior is to not utilize this embedded biometric prompt flow. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setDefaultIconPreferredAsSingleProvider(kotlin.Boolean)( boolean isDefaultIconPreferredAsSingleProvider )` When set to true, the UI prefers to render the default credential type icon when you are the single available provider; false by default. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setDisplayName(kotlin.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence.html displayName)` Sets a displayName to be shown on the UI with this entry. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setIcon(android.graphics.drawable.Icon)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/drawable/Icon.html icon)` Sets the icon to be shown on the UI with this entry. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder` | `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder#setLastUsedTime(java.time.Instant)(https://developer.android.com/reference/java/time/Instant.html lastUsedTime)` Sets the last used time of this account. |

## Public constructors

### Builder

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

```
public Builder(
    @NonNull Context context,
    @NonNull CharSequence username,
    @NonNull PendingIntent pendingIntent,
    @NonNull BeginGetPasswordOption beginGetPasswordOption
)
```

constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry.Builder`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | the context of the calling app, required to retrieve fallback resources |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html username` | the username of the account holding the password credential |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent` | the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/BeginGetPasswordOption beginGetPasswordOption` | the option from the original `https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse`, for which this credential entry is being added |

## Public methods

### build

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

```
public final @NonNull PasswordCredentialEntry build()
```

Builds an instance of `https://developer.android.com/reference/androidx/credentials/provider/PasswordCredentialEntry`

### setAffiliatedDomain

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

```
public final @NonNull PasswordCredentialEntry.Builder setAffiliatedDomain(CharSequence affiliatedDomain)
```

Sets whether the entry should have an affiliated domain, a CharSequence representation of some larger entity that may be used to bind multiple entries together (e.g. app_one, and app_two may be bound by 'super_app' as the larger affiliation domain) without length limit, default null.

### setAutoSelectAllowed

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

```
public final @NonNull PasswordCredentialEntry.Builder setAutoSelectAllowed(boolean autoSelectAllowed)
```

Sets whether the entry should be auto-selected. The value is false by default.

### setBiometricPromptData

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

```
@RequiresApi(value = 35)
public final @NonNull PasswordCredentialEntry.Builder setBiometricPromptData(BiometricPromptData biometricPromptData)
```

Sets the biometric prompt data to optionally utilize a credential manager flow that directly handles the biometric verification for you and gives you the response; set to null by default, indicating the default behavior is to not utilize this embedded biometric prompt flow.

### setDefaultIconPreferredAsSingleProvider

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

```
public final @NonNull PasswordCredentialEntry.Builder setDefaultIconPreferredAsSingleProvider(
    boolean isDefaultIconPreferredAsSingleProvider
)
```

When set to true, the UI prefers to render the default credential type icon when you are the single available provider; false by default.

### setDisplayName

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

```
public final @NonNull PasswordCredentialEntry.Builder setDisplayName(CharSequence displayName)
```

Sets a displayName to be shown on the UI with this entry.

### setIcon

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

```
public final @NonNull PasswordCredentialEntry.Builder setIcon(@NonNull Icon icon)
```

Sets the icon to be shown on the UI with this entry.

### setLastUsedTime

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

```
public final @NonNull PasswordCredentialEntry.Builder setLastUsedTime(Instant lastUsedTime)
```

Sets the last used time of this account. This information will be used to sort the entries on the selector.