Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/credentials/CredentialOption.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/credentials/CredentialOption.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/credentials/CredentialOption.Builder#inhmethods)

# CredentialOption.Builder

*** ** * ** ***

` public static final class CredentialOption.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.credentials.CredentialOption.Builder |

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/android/credentials/CredentialOption`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder#Builder(java.lang.String,%20android.os.Bundle,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/android/os/Bundle credentialRetrievalData, https://developer.android.com/reference/android/os/Bundle candidateQueryData) ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder#addAllowedProvider(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName allowedProvider) ` Adds a provider `https://developer.android.com/reference/android/content/ComponentName` to be queried while gathering credentials from credential providers on the device. |
| ` https://developer.android.com/reference/android/credentials/CredentialOption` | ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder#build()() ` Builds a `https://developer.android.com/reference/android/credentials/CredentialOption`. |
| ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder#setAllowedProviders(java.util.Set<android.content.ComponentName>)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/android/content/ComponentName> allowedProviders) ` Sets a set of provider `https://developer.android.com/reference/android/content/ComponentName` to be queried while gathering credentials from credential providers on the device. |
| ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | ` https://developer.android.com/reference/android/credentials/CredentialOption.Builder#setIsSystemProviderRequired(boolean)(boolean isSystemProviderRequired) ` Sets a true/false value corresponding to whether this option must be serviced by system credentials providers only. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

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

```
public Builder (String type, 
                Bundle credentialRetrievalData, 
                Bundle candidateQueryData)
```

<br />

<br />

| Parameters ||
|---|---|
| `type` | `String`: the type of the credential option. This value cannot be `null`. <br /> |
| `credentialRetrievalData` | `Bundle`: the full request data. This value cannot be `null`. <br /> |
| `candidateQueryData` | `Bundle`: the partial request data that will be sent to the provider during the initial credential candidate query stage. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `type` is null, or empty |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `credentialRetrievalData`, or `candidateQueryData` is null |

## Public methods

### addAllowedProvider

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

```
public CredentialOption.Builder addAllowedProvider (ComponentName allowedProvider)
```

Adds a provider `https://developer.android.com/reference/android/content/ComponentName` to be queried while gathering credentials from credential providers on the device. If no candidate providers are specified, all user configured and system credential providers will be queried in the candidate query phase. If an invalid component name is provided, or a service corresponding to the component name does not exist on the device, that component name is ignored. If all component names are invalid, or not present on the device, no providers are queried and no credentials are retrieved.

<br />

| Parameters ||
|---|---|
| `allowedProvider` | `ComponentName`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `allowedProvider` is null |

### build

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

```
public CredentialOption build ()
```

Builds a `https://developer.android.com/reference/android/credentials/CredentialOption`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/credentials/CredentialOption` | This value cannot be `null`. <br /> |

### setAllowedProviders

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

```
public CredentialOption.Builder setAllowedProviders (Set<ComponentName> allowedProviders)
```

Sets a set of provider `https://developer.android.com/reference/android/content/ComponentName` to be queried while gathering credentials from credential providers on the device. If no candidate providers are specified, all user configured and system credential providers will be queried in the candidate query phase. If an invalid component name is provided, or a service corresponding to the component name does not exist on the device, that component name is ignored. If all component names are invalid, or not present on the device, no providers are queried and no credentials are retrieved.

<br />

| Parameters ||
|---|---|
| `allowedProviders` | `Set`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `allowedProviders` is null, or any of its elements are null. |

### setIsSystemProviderRequired

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

```
public CredentialOption.Builder setIsSystemProviderRequired (boolean isSystemProviderRequired)
```

Sets a true/false value corresponding to whether this option must be serviced by system credentials providers only.

<br />

| Parameters ||
|---|---|
| `isSystemProviderRequired` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/credentials/CredentialOption.Builder` | This value cannot be `null`. <br /> |