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

# AssociationRequest.Builder

*** ** * ** ***


`
public
static
final

class
AssociationRequest.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/android/companion/AssociationRequest`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#addDeviceFilter(android.companion.DeviceFilter<?>)(https://developer.android.com/reference/android/companion/DeviceFilter<?> deviceFilter) ` |
| ` https://developer.android.com/reference/android/companion/AssociationRequest` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#build()() ` |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setDeviceIcon(android.graphics.drawable.Icon)(https://developer.android.com/reference/android/graphics/drawable/Icon deviceIcon) ` Set the device icon for the self-managed device and to display the icon in the self-managed association dialog. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setDeviceProfile(java.lang.String)(https://developer.android.com/reference/java/lang/String deviceProfile) ` If set, association will be requested as a corresponding kind of device |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setDisplayName(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence displayName) ` Adds a display name. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setExtraPermissions(java.util.Set<java.lang.String>)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String> permissions) ` Sets the set of extra permissions to be requested for this association. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setForceConfirmation(boolean)(boolean forceConfirmation) ` Indicates whether the application requires the `https://developer.android.com/reference/android/companion/CompanionDeviceManager` service to collect an explicit confirmation from the user before creating an association, even if such confirmation is not required from the service's perspective. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setRemoteAiAgentSupported(boolean)(boolean remoteAiAgentSupported) ` Indicates whether the device is capable of interacting with a remote AI agent on another device. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setSelfManaged(boolean)(boolean selfManaged) ` Indicate whether the association would be managed by the companion application. |
| ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder` | ` https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setSingleDevice(boolean)(boolean singleDevice) ` Whether only a single device should match the provided filter. |

| ### 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 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

<br />

<br />

## Public methods

### addDeviceFilter

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

```
public AssociationRequest.Builder addDeviceFilter (DeviceFilter<?> deviceFilter)
```

<br />

<br />

| Parameters ||
|---|---|
| `deviceFilter` | `DeviceFilter`: if set, only devices matching the given filter will be shown to the user. This value may be `null`. <br /> |

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

### build

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

```
public AssociationRequest build ()
```

<br />

<br />

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

### setDeviceIcon

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public AssociationRequest.Builder setDeviceIcon (Icon deviceIcon)
```

Set the device icon for the self-managed device and to display the icon in the
self-managed association dialog.

The given device icon will be resized to 24dp x 24dp.


Requires `https://developer.android.com/reference/android/Manifest.permission#REQUEST_COMPANION_SELF_MANAGED`

<br />

| Parameters ||
|---|---|
| `deviceIcon` | `Icon`: This value cannot be `null`. <br /> |

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

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the icon is `https://developer.android.com/reference/android/graphics/drawable/Icon#TYPE_URI` or `https://developer.android.com/reference/android/graphics/drawable/Icon#TYPE_URI_ADAPTIVE_BITMAP`. |

**See also:**

- `https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setSelfManaged(boolean)`

### setDeviceProfile

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

```
public AssociationRequest.Builder setDeviceProfile (String deviceProfile)
```

If set, association will be requested as a corresponding kind of device

<br />

| Parameters ||
|---|---|
| `deviceProfile` | `String`: This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_WATCH` - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_COMPUTER` - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_AUTOMOTIVE_PROJECTION` - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_APP_STREAMING` - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_GLASSES` - `https://developer.android.com/reference/android/companion/AssociationRequest#DEVICE_PROFILE_NEARBY_DEVICE_STREAMING` |

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

### setDisplayName

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

```
public AssociationRequest.Builder setDisplayName (CharSequence displayName)
```

Adds a display name.
Generally `https://developer.android.com/reference/android/companion/AssociationRequest`s are not required to provide a display name, except
for request for creating "self-managed" associations, which MUST provide a display name.

<br />

| Parameters ||
|---|---|
| `displayName` | `CharSequence`: the display name of the device. This value cannot be `null`. <br /> |

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

### setExtraPermissions

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

```
public AssociationRequest.Builder setExtraPermissions (Set<String> permissions)
```

Sets the set of extra permissions to be requested for this association.

These permissions will be granted to the companion app upon a successful association.
Users can manually grant or revoke these permissions through the system settings.
This API will not overwrite any permission status that a user has manually set.

When a device is disassociated, the system will attempt to revoke the permissions
that were granted for it. This revocation will also not override any permissions that the
user has manually set.

<br />

| Parameters ||
|---|---|
| `permissions` | `Set`: a non-null set of permissions from `https://developer.android.com/`. <br /> |

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

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the provided `permissions` set is empty or contains any unsupported permissions. |

### setForceConfirmation

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

```
public AssociationRequest.Builder setForceConfirmation (boolean forceConfirmation)
```

Indicates whether the application requires the `https://developer.android.com/reference/android/companion/CompanionDeviceManager` service to
collect an explicit confirmation from the user before creating an association, even if
such confirmation is not required from the service's perspective.


Requires `https://developer.android.com/reference/android/Manifest.permission#REQUEST_COMPANION_SELF_MANAGED`

<br />

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

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

### setRemoteAiAgentSupported

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

```
public AssociationRequest.Builder setRemoteAiAgentSupported (boolean remoteAiAgentSupported)
```

Indicates whether the device is capable of interacting with a remote AI agent on another
device.

Default value is `false`. When set to `true`, this allows the device
(e.g., a microphone or a smart wearable) to act as an input/output source for a remote
AI agent.

Setting this flag to `true` modifies the user-facing association dialog to
include relevant AI usage disclosures.

<br />

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

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

### setSelfManaged

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

```
public AssociationRequest.Builder setSelfManaged (boolean selfManaged)
```

Indicate whether the association would be managed by the companion application.

Requests for creating "self-managed" association MUST provide a Display name.


Requires `https://developer.android.com/reference/android/Manifest.permission#REQUEST_COMPANION_SELF_MANAGED`

<br />

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

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

**See also:**

- `https://developer.android.com/reference/android/companion/AssociationRequest.Builder#setDisplayName(java.lang.CharSequence)`

### setSingleDevice

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

```
public AssociationRequest.Builder setSingleDevice (boolean singleDevice)
```

Whether only a single device should match the provided filter.

When scanning for a single device with a specific `https://developer.android.com/reference/android/companion/BluetoothDeviceFilter` mac
address, bonded devices are also searched among. This allows to obtain the necessary app
privileges even if the device is already paired.

<br />

| Parameters ||
|---|---|
| `singleDevice` | `boolean`: if true, scanning for a device will stop as soon as at least one fitting device is found <br /> |

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