AssociationRequest.Builder
public
static
final
class
AssociationRequest.Builder
extends Object
java.lang.Object | |
↳ | android.companion.AssociationRequest.Builder |
A builder for 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
|
setForceConfirmation(boolean forceConfirmation)
Indicates whether the application requires the |
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 | |
---|---|
Public constructors
Public methods
addDeviceFilter
public AssociationRequest.Builder addDeviceFilter (DeviceFilter<?> deviceFilter)
Parameters | |
---|---|
deviceFilter |
DeviceFilter : if set, only devices matching the given filter will be shown to the
user
This value may be null . |
Returns | |
---|---|
AssociationRequest.Builder |
This value cannot be null . |
setDeviceIcon
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 Manifest.permission.REQUEST_COMPANION_SELF_MANAGED
Parameters | |
---|---|
deviceIcon |
Icon : This value cannot be null . |
Returns | |
---|---|
AssociationRequest.Builder |
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the icon is
Icon.TYPE_URI or Icon.TYPE_URI_ADAPTIVE_BITMAP . |
See also:
setDeviceProfile
public AssociationRequest.Builder setDeviceProfile (String deviceProfile)
If set, association will be requested as a corresponding kind of device
Parameters | |
---|---|
deviceProfile |
String : This value cannot be null .
Value is AssociationRequest.DEVICE_PROFILE_WATCH , AssociationRequest.DEVICE_PROFILE_COMPUTER , AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION , AssociationRequest.DEVICE_PROFILE_APP_STREAMING , AssociationRequest.DEVICE_PROFILE_GLASSES , AssociationRequest.DEVICE_PROFILE_NEARBY_DEVICE_STREAMING , or android.companion.AssociationRequest.DEVICE_PROFILE_WEARABLE_SENSING |
Returns | |
---|---|
AssociationRequest.Builder |
This value cannot be null . |
setDisplayName
public AssociationRequest.Builder setDisplayName (CharSequence displayName)
Adds a display name.
Generally 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 . |
setForceConfirmation
public 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.
Requires Manifest.permission.REQUEST_COMPANION_SELF_MANAGED
Parameters | |
---|---|
forceConfirmation |
boolean |
Returns | |
---|---|
AssociationRequest.Builder |
This value cannot be null . |
setSelfManaged
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 Manifest.permission.REQUEST_COMPANION_SELF_MANAGED
Parameters | |
---|---|
selfManaged |
boolean |
Returns | |
---|---|
AssociationRequest.Builder |
This value cannot be null . |
See also:
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
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 . |