Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/companion/DeviceId.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/companion/DeviceId.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/companion/DeviceId.Builder#inhmethods)

# DeviceId.Builder

*** ** * ** ***


`
public
static
final

class
DeviceId.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.companion.DeviceId.Builder |

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/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/android/companion/DeviceId.Builder#setCustomId(java.lang.String)`, or a MAC address using
`https://developer.android.com/reference/android/companion/DeviceId.Builder#setMacAddress(android.net.MacAddress)`.

<br />

## Summary

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

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/companion/DeviceId` | ` https://developer.android.com/reference/android/companion/DeviceId.Builder#build()() ` |
| ` https://developer.android.com/reference/android/companion/DeviceId.Builder` | ` https://developer.android.com/reference/android/companion/DeviceId.Builder#setCustomId(java.lang.String)(https://developer.android.com/reference/java/lang/String customId) ` Sets the custom device id. |
| ` https://developer.android.com/reference/android/companion/DeviceId.Builder` | ` https://developer.android.com/reference/android/companion/DeviceId.Builder#setMacAddress(android.net.MacAddress)(https://developer.android.com/reference/android/net/MacAddress macAddress) ` Sets the mac address. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### Builder

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

```
public Builder ()
```

<br />

<br />

## Public methods

### build

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

```
public DeviceId build ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/companion/DeviceId` | This value cannot be `null`. <br /> |

### setCustomId

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

```
public DeviceId.Builder setCustomId (String customId)
```

Sets the custom device id. This id is used by the Companion app to
identify a specific device.

<br />

| Parameters ||
|---|---|
| `customId` | `String`: the custom device id. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/companion/DeviceId.Builder` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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#ApiLevels)

```
public DeviceId.Builder setMacAddress (MacAddress macAddress)
```

Sets the mac address. This mac address is used by the Companion app to
identify a specific device.

<br />

| Parameters ||
|---|---|
| `macAddress` | `MacAddress`: the remote device mac address. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/companion/DeviceId.Builder` | This value cannot be `null`. <br /> |