Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.companion.DeviceId.Builder](https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#) |

A builder for `https://developer.android.com/reference/kotlin/android/companion/DeviceId`

Calling apps must provide at least one of the following to identify the device: a custom ID using `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#setCustomId(kotlin.String)`, or a MAC address using `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#setMacAddress(android.net.MacAddress)`.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#Builder()()` <br /> |

| Public methods ||
|---|---|
| [DeviceId](https://developer.android.com/reference/kotlin/android/companion/DeviceId) | `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#build()()` <br /> |
| [DeviceId.Builder](https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#) | `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#setCustomId(kotlin.String)(customId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Sets the custom device id. |
| [DeviceId.Builder](https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#) | `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#setMacAddress(android.net.MacAddress)(macAddress: https://developer.android.com/reference/kotlin/android/net/MacAddress.html#?)` Sets the mac address. |

## Public constructors

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder()
```

## Public methods

### build

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): DeviceId
```

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/companion/DeviceId` | This value cannot be `null`. |

### setCustomId

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: the custom device id. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#` | This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | length of the custom id must be at most 1024 characters to save disk space. |

### setMacAddress

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/reference/kotlin/android/net/MacAddress.html#)?: the remote device mac address. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/companion/DeviceId.Builder#` | This value cannot be `null`. |