Builder
class Builder
| kotlin.Any | |
| ↳ | android.companion.AssociationRequest.Builder |
A builder for AssociationRequest
Summary
| Public constructors | |
|---|---|
Builder() |
|
| Public methods | |
|---|---|
| AssociationRequest.Builder |
addDeviceFilter(deviceFilter: DeviceFilter<*>?) |
| AssociationRequest |
build() |
| AssociationRequest.Builder |
setDeviceIcon(deviceIcon: Icon)Set the device icon for the self-managed device and to display the icon in the self-managed association dialog. |
| AssociationRequest.Builder |
setDeviceProfile(deviceProfile: String)If set, association will be requested as a corresponding kind of device |
| AssociationRequest.Builder |
setDisplayName(displayName: CharSequence)Adds a display name. |
| AssociationRequest.Builder |
setExtraPermissions(permissions: MutableSet<String!>)Sets the set of extra permissions to be requested for this association. |
| AssociationRequest.Builder |
setForceConfirmation(forceConfirmation: Boolean)Indicates whether the application requires the |
| AssociationRequest.Builder |
setSelfManaged(selfManaged: Boolean)Indicate whether the association would be managed by the companion application. |
| AssociationRequest.Builder |
setSingleDevice(singleDevice: Boolean)Whether only a single device should match the provided filter. |
Public constructors
Public methods
addDeviceFilter
fun addDeviceFilter(deviceFilter: DeviceFilter<*>?): AssociationRequest.Builder
| Parameters | |
|---|---|
deviceFilter |
DeviceFilter<*>?: if set, only devices matching the given filter will be shown to the user. This value may be null. |
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
build
fun build(): AssociationRequest
| Return | |
|---|---|
AssociationRequest |
This value cannot be null. |
setDeviceIcon
fun setDeviceIcon(deviceIcon: Icon): AssociationRequest.Builder
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 android.Manifest.permission#REQUEST_COMPANION_SELF_MANAGED
| Parameters | |
|---|---|
deviceIcon |
Icon: This value cannot be null. |
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the icon is Icon.TYPE_URI or Icon.TYPE_URI_ADAPTIVE_BITMAP. |
See Also
setDeviceProfile
fun setDeviceProfile(deviceProfile: String): AssociationRequest.Builder
If set, association will be requested as a corresponding kind of device
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
setDisplayName
fun setDisplayName(displayName: CharSequence): AssociationRequest.Builder
Adds a display name. Generally AssociationRequests 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. |
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
setExtraPermissions
fun setExtraPermissions(permissions: MutableSet<String!>): AssociationRequest.Builder
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 |
MutableSet<String!>: a non-null set of permissions from android.companion.AssociationRequest.Permission. |
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the provided permissions set is empty or contains any unsupported permissions. |
setForceConfirmation
fun setForceConfirmation(forceConfirmation: Boolean): AssociationRequest.Builder
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.
Requires android.Manifest.permission#REQUEST_COMPANION_SELF_MANAGED
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
setSelfManaged
fun setSelfManaged(selfManaged: Boolean): AssociationRequest.Builder
Indicate whether the association would be managed by the companion application. Requests for creating "self-managed" association MUST provide a Display name.
Requires android.Manifest.permission#REQUEST_COMPANION_SELF_MANAGED
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |
See Also
setSingleDevice
fun setSingleDevice(singleDevice: Boolean): AssociationRequest.Builder
Whether only a single device should match the provided filter. When scanning for a single device with a specific 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 |
| Return | |
|---|---|
AssociationRequest.Builder |
This value cannot be null. |