Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
A builder for ObservingDevicePresenceRequest
Summary
Public constructors
Public methods
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-13 UTC."],[],[],null,["# ObservingDevicePresenceRequest.Builder\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/companion/ObservingDevicePresenceRequest.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|---------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.companion.ObservingDevicePresenceRequest.Builder](#) |\n\nA builder for [ObservingDevicePresenceRequest](/reference/kotlin/android/companion/ObservingDevicePresenceRequest)\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------|---|\n| [Builder](#Builder())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [ObservingDevicePresenceRequest](/reference/kotlin/android/companion/ObservingDevicePresenceRequest) | [build](#build())`()` \u003cbr /\u003e |\n| [ObservingDevicePresenceRequest.Builder](#) | [setAssociationId](#setAssociationId(kotlin.Int))`(`associationId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the association id to be observed for device presence. |\n| [ObservingDevicePresenceRequest.Builder](#) | [setUuid](#setUuid(android.os.ParcelUuid))`(`uuid:` `[ParcelUuid](../os/ParcelUuid.html#)`)` Set the ParcelUuid to be observed for device presence. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder()\n```\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): ObservingDevicePresenceRequest\n```\n\n| Return ||\n|------------------------------------------------------------------------------------------------------|------------------------------|\n| [ObservingDevicePresenceRequest](/reference/kotlin/android/companion/ObservingDevicePresenceRequest) | This value cannot be `null`. |\n\n### setAssociationId\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setAssociationId(associationId: Int): ObservingDevicePresenceRequest.Builder\n```\n\nSet the association id to be observed for device presence.\n\nThe provided device must be android.companion.CompanionDeviceManager#associate with the calling app before calling this method if using this API. Caller must implement a single [CompanionDeviceService](/reference/kotlin/android/companion/CompanionDeviceService) which will be bound to and receive callbacks to [CompanionDeviceService.onDevicePresenceEvent(DevicePresenceEvent)](/reference/kotlin/android/companion/CompanionDeviceService#onDevicePresenceEvent(android.companion.DevicePresenceEvent)).\n\nCalling apps must use either [setUuid(android.os.ParcelUuid)](#setUuid(android.os.ParcelUuid)) or this API, but not both.\n\n| Parameters ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `associationId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The association id for observing device presence. |\n\n| Return ||\n|---------------------------------------------|------------------------------|\n| [ObservingDevicePresenceRequest.Builder](#) | This value cannot be `null`. |\n\n### setUuid\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setUuid(uuid: ParcelUuid): ObservingDevicePresenceRequest.Builder\n```\n\nSet the ParcelUuid to be observed for device presence.\n\nIt does not require to create the association before calling this API. This only supports classic Bluetooth scan and caller must implement a single [CompanionDeviceService](/reference/kotlin/android/companion/CompanionDeviceService) which will be bound to and receive callbacks to [CompanionDeviceService.onDevicePresenceEvent(DevicePresenceEvent)](/reference/kotlin/android/companion/CompanionDeviceService#onDevicePresenceEvent(android.companion.DevicePresenceEvent)).\n\nThe Uuid should be matching one of the ParcelUuid form [android.bluetooth.BluetoothDevice#getUuids()](../bluetooth/BluetoothDevice.html#getUuids())\n\nCalling apps must use either this API or [setAssociationId(int)](#setAssociationId(kotlin.Int)), but not both.\n\nCalling app must hold the [AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION](/reference/kotlin/android/companion/AssociationRequest#DEVICE_PROFILE_AUTOMOTIVE_PROJECTION:kotlin.String) profile.\n\nRequires [android.Manifest.permission#REQUEST_OBSERVE_DEVICE_UUID_PRESENCE](../Manifest.permission.html#REQUEST_OBSERVE_DEVICE_UUID_PRESENCE:kotlin.String) and [android.Manifest.permission#BLUETOOTH_CONNECT](../Manifest.permission.html#BLUETOOTH_CONNECT:kotlin.String) and [android.Manifest.permission#BLUETOOTH_SCAN](../Manifest.permission.html#BLUETOOTH_SCAN:kotlin.String)\n\n| Parameters ||\n|--------|------------------------------------------------------------------------------------------------------------------|\n| `uuid` | [ParcelUuid](../os/ParcelUuid.html#): The ParcelUuid for observing device presence. This value cannot be `null`. |\n\n| Return ||\n|---------------------------------------------|------------------------------|\n| [ObservingDevicePresenceRequest.Builder](#) | This value cannot be `null`. |"]]