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

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/ranging/SessionConfig.Builder "View this page in Java")

```
class Builder
```

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

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

## Summary

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

| Public methods ||
|---|---|
| [SessionConfig](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#build()()` Builds a new `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig` instance. |
| [SessionConfig.Builder](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#setAngleOfArrivalNeeded(kotlin.Boolean)(isAngleOfArrivalNeeded: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether Angle of Arrival (AoA) is required for the ranging operation. |
| [SessionConfig.Builder](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#setAntennaMode(kotlin.Int)(antennaMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the antenna mode for the ranging session which helps in determining the optimal antennas to use for Tx and Rx. |
| [SessionConfig.Builder](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#setDataNotificationConfig(android.ranging.DataNotificationConfig)(config: https://developer.android.com/reference/kotlin/android/ranging/DataNotificationConfig)` Sets the data notification configuration for this preference. |
| [SessionConfig.Builder](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#setRangingMeasurementsLimit(kotlin.Int)(rangingMeasurementsLimit: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the maximum number of ranging rounds for this session. |
| [SessionConfig.Builder](https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#setSensorFusionParams(android.ranging.SensorFusionParams)(parameters: https://developer.android.com/reference/kotlin/android/ranging/SensorFusionParams)` Sets the sensor fusion parameters for this preference. |

## 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(): SessionConfig
```

Builds a new `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig` instance.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig` | the new `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig` instance. This value cannot be `null`. |

### setAngleOfArrivalNeeded

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

```
fun setAngleOfArrivalNeeded(isAngleOfArrivalNeeded: Boolean): SessionConfig.Builder
```

Sets whether Angle of Arrival (AoA) is required for the ranging operation.

Defaults to false

| Parameters ||
|---|---|
| `isAngleOfArrivalNeeded` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if AoA data is required; `false` otherwise. |

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

### setAntennaMode

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

```
fun setAntennaMode(antennaMode: Int): SessionConfig.Builder
```

Sets the antenna mode for the ranging session which helps in determining the optimal antennas to use for Tx and Rx.

- This should be set to `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig#ANTENNA_MODE_DIRECTIONAL:kotlin.Int` for foreground use-cases like Finder where the user is actively using the device to find another device (longer range in a particular direction).
- This should be set to `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig#ANTENNA_MODE_OMNI:kotlin.Int` for background use-cases like background use-cases like passive unlock when the user is passively using the device to unlock another device (shorter range in all directions).
Check `https://developer.android.com/reference/kotlin/android/ranging/uwb/UwbRangingCapabilities#getSupportedAntennaModes()` for supported antenna modes on the device. If the mode requested here is not supported, the session will be immediately closed - android.ranging.RangingSession#onClosed(int).

| Parameters ||
|---|---|
| `antennaMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the antenna mode android.ranging.SessionConfig.AntennaMode Value is one of the following: - `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig#ANTENNA_MODE_OMNI:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig#ANTENNA_MODE_DIRECTIONAL:kotlin.Int` |

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

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

### setDataNotificationConfig

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

```
fun setDataNotificationConfig(config: DataNotificationConfig): SessionConfig.Builder
```

Sets the data notification configuration for this preference.

| Parameters ||
|---|---|
| `config` | [DataNotificationConfig](https://developer.android.com/reference/kotlin/android/ranging/DataNotificationConfig): the `https://developer.android.com/reference/kotlin/android/ranging/DataNotificationConfig` to use. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#` | the builder instance for chaining. This value cannot be `null`. |

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

### setRangingMeasurementsLimit

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

```
fun setRangingMeasurementsLimit(rangingMeasurementsLimit: Int): SessionConfig.Builder
```

Sets the maximum number of ranging rounds for this session. This includes all ranging rounds, irrespective of whether they were successful or not. For 1:many sessions, a round includes ranging to all peers within that round.

By default, when the value is set to `0`, the ranging session will run indefinitely.

| Parameters ||
|---|---|
| `rangingMeasurementsLimit` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the maximum number of ranging rounds (0 to 65535). Value is between 0 and 65535 inclusive |

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

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the value is outside the allowed range (0 to 65535). |

### setSensorFusionParams

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

```
fun setSensorFusionParams(parameters: SensorFusionParams): SessionConfig.Builder
```

Sets the sensor fusion parameters for this preference.

| Parameters ||
|---|---|
| `parameters` | [SensorFusionParams](https://developer.android.com/reference/kotlin/android/ranging/SensorFusionParams): the `https://developer.android.com/reference/kotlin/android/ranging/SensorFusionParams` to use. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/SessionConfig.Builder#` | the builder instance. This value cannot be `null`. |

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