AssociationRequest.Builder | API reference | Android Developers (original) (raw)
public static final class AssociationRequest.Builderextends [Object](/reference/java/lang/Object) ``
A builder for [AssociationRequest](/reference/android/companion/AssociationRequest)
Summary
| Public constructors |
|---|
| Builder() |
| Public methods | |
|---|---|
| AssociationRequest.Builder | addDeviceFilter(DeviceFilter<?> deviceFilter) |
| AssociationRequest | build() |
| 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. |
| AssociationRequest.Builder | setDeviceProfile(String deviceProfile) If set, association will be requested as a corresponding kind of device |
| AssociationRequest.Builder | setDisplayName(CharSequence displayName) Adds a display name. |
| AssociationRequest.Builder | setExtraPermissions(Set<String> permissions) Sets the set of extra permissions to be requested for this association. |
| AssociationRequest.Builder | setForceConfirmation(boolean forceConfirmation) Indicates whether the application requires the 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. |
| AssociationRequest.Builder | setRemoteAiAgentSupported(boolean remoteAiAgentSupported) Indicates whether the device is capable of interacting with a remote AI agent on another device. |
| AssociationRequest.Builder | setSelfManaged(boolean selfManaged) Indicate whether the association would be managed by the companion application. |
| AssociationRequest.Builder | setSingleDevice(boolean singleDevice) Whether only a single device should match the provided filter. |
| Inherited methods |
|---|
| From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(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 wait(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 wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
Public constructors
Builder
public Builder ()
Public methods
setDisplayName
public AssociationRequest.Builder setDisplayName (CharSequence displayName)
Adds a display name. Generally [AssociationRequest](/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.
| Parameters | |
|---|---|
| displayName | CharSequence: the display name of the device. This value cannot be null. |
| Returns | |
|---|---|
| AssociationRequest.Builder | This value cannot be null. |
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.
| Parameters | |
|---|---|
| permissions | Set: a non-null set of permissions fromERROR(/android.companion.AssociationRequest.Permission). |
| Returns | |
|---|---|
| AssociationRequest.Builder | This value cannot be null. |
| Throws | |
|---|---|
| IllegalArgumentException | if the provided permissions set is empty or contains any unsupported permissions. |
setRemoteAiAgentSupported
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.
| Parameters | |
|---|---|
| remoteAiAgentSupported | boolean |
| Returns | |
|---|---|
| AssociationRequest.Builder | This value cannot be null. |
setSingleDevice
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 [BluetoothDeviceFilter](/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.
| Parameters | |
|---|---|
| singleDevice | boolean: if true, scanning for a device will stop as soon as at least one fitting device is found |
| Returns | |
|---|---|
| AssociationRequest.Builder | This value cannot be null. |