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.ranging.uwb.UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) |

Builder class for creating instances of `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams`

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#Builder(kotlin.Int,%20kotlin.Int,%20android.ranging.uwb.UwbAddress,%20android.ranging.uwb.UwbAddress)(sessionId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, configId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, deviceAddress: https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress, peerAddress: https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress)` Constructs a new `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` for creating a ranging session. |

| Public methods ||
|---|---|
| [UwbRangingParams](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#build()()` Builds a new instance of `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams`. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setComplexChannel(android.ranging.uwb.UwbComplexChannel)(complexChannel: https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbComplexChannel)` Sets the complex channel configuration for the ranging session. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setRangingUpdateRate(kotlin.Int)(rate: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the ranging update rate for the session. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setSessionKeyInfo(kotlin.ByteArray)(sessionKeyInfo: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)` Sets the session key information for secure ranging. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setSlotDuration(kotlin.Int)(durationMs: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the slot duration in milliseconds for the ranging session. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setSubSessionId(kotlin.Int)(subSessionId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the sub-session ID for the ranging session. |
| [UwbRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#setSubSessionKeyInfo(kotlin.ByteArray)(subSessionKeyInfo: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)` Sets the sub-session key information for secure ranging. |

## Public constructors

### Builder

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

```
Builder(
    sessionId: Int, 
    configId: Int, 
    deviceAddress: UwbAddress, 
    peerAddress: UwbAddress)
```

Constructs a new `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` for creating a ranging session.

| Parameters ||
|---|---|
| `sessionId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): A unique identifier for the session. |
| `configId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The configuration ID for the ranging parameters. |
| `deviceAddress` | [UwbAddress](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress): The `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress` representing the device's address. Must be non-null. |
| `peerAddress` | [UwbAddress](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress): The `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbAddress` of the peer device. Must be non-null. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if either `deviceAddress` or `peerAddress` is null. |

## Public methods

### build

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

```
fun build(): UwbRangingParams
```

Builds a new instance of `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams` | a new instance of `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams` created using the current state of the builder. This value cannot be `null`. |

### setComplexChannel

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

```
fun setComplexChannel(complexChannel: UwbComplexChannel): UwbRangingParams.Builder
```

Sets the complex channel configuration for the ranging session.

| Parameters ||
|---|---|
| `complexChannel` | [UwbComplexChannel](https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbComplexChannel): a non-null `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbComplexChannel` instance representing the channel and preamble configuration. For better performance always use a random preamble index for each ranging session. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the provided complex channel is null. |

### setRangingUpdateRate

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

```
fun setRangingUpdateRate(rate: Int): UwbRangingParams.Builder
```

Sets the ranging update rate for the session.

Defaults to android.ranging.raw.RawRangingDevice.RangingUpdateRate#UPDATE_RATE_NORMAL.

| Parameters ||
|---|---|
| `rate` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the ranging update rate, defined as one of the constants in android.ranging.raw.RawRangingDevice.RangingUpdateRate. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance. This value cannot be `null`. |

### setSessionKeyInfo

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

```
fun setSessionKeyInfo(sessionKeyInfo: ByteArray): UwbRangingParams.Builder
```

Sets the session key information for secure ranging.

| Parameters ||
|---|---|
| `sessionKeyInfo` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html): a byte array containing session key information. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the provided byte array is null. |

### setSlotDuration

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

```
fun setSlotDuration(durationMs: Int): UwbRangingParams.Builder
```

Sets the slot duration in milliseconds for the ranging session.

Defaults to `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams#DURATION_2_MS:kotlin.Int`.

| Parameters ||
|---|---|
| `durationMs` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the slot duration android.ranging.uwb.UwbRangingParams.SlotDuration Value is one of the following: - `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams#DURATION_1_MS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams#DURATION_2_MS:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the provided duration is out of range. |

### setSubSessionId

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

```
fun setSubSessionId(subSessionId: Int): UwbRangingParams.Builder
```

Sets the sub-session ID for the ranging session.

| Parameters ||
|---|---|
| `subSessionId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the sub-session ID, which should be a unique identifier for the sub-session. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance for method chaining. This value cannot be `null`. |

### setSubSessionKeyInfo

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

```
fun setSubSessionKeyInfo(subSessionKeyInfo: ByteArray): UwbRangingParams.Builder
```

Sets the sub-session key information for secure ranging.

| Parameters ||
|---|---|
| `subSessionKeyInfo` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html): a byte array containing sub-session key information. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingParams.Builder#` | this Builder instance. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the provided map is null. |