Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
A builder for DeviceId
Calling apps must provide at least one of the following to identify the device: a custom ID using setCustomId(java.lang.String)
, or a MAC address using setMacAddress(android.net.MacAddress)
.
Summary
Public constructors
Public methods
setCustomId
fun setCustomId(customId: String?): DeviceId.Builder
Sets the custom device id. This id is used by the Companion app to identify a specific device.
Parameters |
customId |
String?: the custom device id This value may be null . |
Exceptions |
java.lang.IllegalArgumentException |
length of the custom id must more than 1024 characters to save disk space. |
setMacAddress
fun setMacAddress(macAddress: MacAddress?): DeviceId.Builder
Sets the mac address. This mac address is used by the Companion app to identify a specific device.
Parameters |
macAddress |
MacAddress?: the remote device mac address This value may be null . |
Exceptions |
java.lang.IllegalArgumentException |
length of the custom id must more than 1024 characters to save disk space. |
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,["# DeviceId.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/DeviceId.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.DeviceId.Builder](#) |\n\nA builder for [DeviceId](/reference/kotlin/android/companion/DeviceId)\n\nCalling apps must provide at least one of the following to identify the device: a custom ID using [setCustomId(java.lang.String)](#setCustomId(kotlin.String)), or a MAC address using [setMacAddress(android.net.MacAddress)](#setMacAddress(android.net.MacAddress)).\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------|---|\n| [Builder](#Builder())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [DeviceId](/reference/kotlin/android/companion/DeviceId) | [build](#build())`()` \u003cbr /\u003e |\n| [DeviceId.Builder](#) | [setCustomId](#setCustomId(kotlin.String))`(`customId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets the custom device id. |\n| [DeviceId.Builder](#) | [setMacAddress](#setMacAddress(android.net.MacAddress))`(`macAddress:` `[MacAddress](../net/MacAddress.html#)?`)` Sets the mac address. |\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(): DeviceId\n```\n\n| Return ||\n|----------------------------------------------------------|------------------------------|\n| [DeviceId](/reference/kotlin/android/companion/DeviceId) | This value cannot be `null`. |\n\n### setCustomId\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setCustomId(customId: String?): DeviceId.Builder\n```\n\nSets the custom device id. This id is used by the Companion app to identify a specific device.\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `customId` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: the custom device id This value may be `null`. |\n\n| Return ||\n|-----------------------|------------------------------|\n| [DeviceId.Builder](#) | This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|----------------------------------------------------------------------------|\n| `java.lang.IllegalArgumentException` | length of the custom id must more than 1024 characters to save disk space. |\n\n### setMacAddress\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setMacAddress(macAddress: MacAddress?): DeviceId.Builder\n```\n\nSets the mac address. This mac address is used by the Companion app to identify a specific device.\n\n| Parameters ||\n|--------------|-------------------------------------------------------------------------------------------------|\n| `macAddress` | [MacAddress](../net/MacAddress.html#)?: the remote device mac address This value may be `null`. |\n\n| Return ||\n|-----------------------|------------------------------|\n| [DeviceId.Builder](#) | This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|----------------------------------------------------------------------------|\n| `java.lang.IllegalArgumentException` | length of the custom id must more than 1024 characters to save disk space. |"]]