Added in [API level 28](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.net.wifi.rtt.RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) |

Builder class used to construct `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#Builder()()` <br /> |

| Public methods ||
|---|---|
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addAccessPoint(android.net.wifi.ScanResult)(apInfo: https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#)` Add the device specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#` to the list of devices with which to measure range. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addAccessPoints(kotlin.collections.MutableList)(apInfos: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#!>)` Add the devices specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#`s to the list of devices with which to measure range. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addNon80211mcCapableAccessPoint(android.net.wifi.ScanResult)(apInfo: https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#)` Add the non-802. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addNon80211mcCapableAccessPoints(kotlin.collections.MutableList)(apInfos: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#!>)` Add the non-802. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addResponder(android.net.wifi.rtt.ResponderConfig)(responder: https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig)` Add the Responder device specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig` to the list of devices with which to measure range. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addResponders(kotlin.collections.MutableList)(responders: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig!>)` Add the devices specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig`s to the list of devices with which to measure range. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addWifiAwarePeer(android.net.MacAddress)(peerMacAddress: https://developer.android.com/reference/kotlin/android/net/MacAddress.html#)` Add the device specified by the `peerMacAddress` to the list of devices with which to measure range. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#addWifiAwarePeer(android.net.wifi.aware.PeerHandle)(peerHandle: https://developer.android.com/reference/kotlin/android/net/wifi/aware/PeerHandle.html#)` Add a device specified by a `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PeerHandle.html#` to the list of devices with which to measure range. |
| [RangingRequest](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest)! | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#build()()` Build `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest` given the current configurations made on the builder. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#setRttBurstSize(kotlin.Int)(rttBurstSize: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the RTT Burst size for the ranging request. |
| [RangingRequest.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#setSecurityMode(kotlin.Int)(securityMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the overall security mode for ranging, determining if secure ranging is attempted with each responder and if fallback to unauthenticated secure ranging is permitted. |

## Public constructors

### Builder

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

```
Builder()
```

## Public methods

### addAccessPoint

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

```
fun addAccessPoint(apInfo: ScanResult): RangingRequest.Builder
```

Add the device specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#` to the list of devices with which to measure range. The total number of peers added to a request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Two-sided Ranging will be performed if the local device and the AP support IEEE 802.11az (non-trigger based ranging) or IEEE 802.11mc. AP capability is determined by the method `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` or `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()`. If both 11az and 11mc are supported by the local device and the AP, 11az non-trigger based ranging will be performed. If two-sided ranging is not supported, one-sided RTT will be performed with no correction for the AP packet turnaround time.

| Parameters ||
|---|---|
| `apInfo` | [ScanResult](https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#): Information about an Access Point (AP) obtained in a Scan Result. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addAccessPoints

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

```
fun addAccessPoints(apInfos: MutableList<ScanResult!>): RangingRequest.Builder
```

Add the devices specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#`s to the list of devices with which to measure range. The total number of peers added to a request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Two-sided Ranging will be performed if the local device and the AP support IEEE 802.11az (non-trigger based ranging) or IEEE 802.11mc. AP capability is determined by the method `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` or `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()`. If both 11az and 11mc are supported by the local device and the AP, 11az non-trigger based ranging will be performed. If two-sided ranging is not supported, one-sided RTT will be performed with no correction for the AP packet turnaround time.

| Parameters ||
|---|---|
| `apInfos` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[ScanResult](https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#)!\>: Information about Access Points (APs) obtained in a Scan Result. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addNon80211mcCapableAccessPoint

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

```
fun addNon80211mcCapableAccessPoint(apInfo: ScanResult): RangingRequest.Builder
```

Add the non-802.11mc and non-802.11az capable device specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#` to the list of devices with which to measure range. The total number of peers added to a request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Accurate ranging cannot be supported if the Access Point does not support IEEE 802.11mc and IEEE 802.11az, and instead an alternate protocol called one-sided RTT will be used with lower accuracy. Use `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()` to verify the Access Point(s) are not 802.11mc capable. Use `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` ()} to verify the Access Point)s) are not 802.11az capable.

One-sided RTT does not subtract the RTT turnaround time at the Access Point, which can add hundreds of meters to the estimate. With experimentation, it is possible to use this information to make a statistical estimate of the range by taking multiple measurements to several Access Points and normalizing the result. For some applications this can be used to improve range estimates based on Receive Signal Strength Indication (RSSI), but will not be as accurate as IEEE 802.11mc (two-sided RTT).

Note: one-sided RTT should only be used if you are very familiar with statistical estimation techniques.

| Parameters ||
|---|---|
| `apInfo` | [ScanResult](https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#): Information about an Access Point (AP) obtained in a Scan Result. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addNon80211mcCapableAccessPoints

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

```
fun addNon80211mcCapableAccessPoints(apInfos: MutableList<ScanResult!>): RangingRequest.Builder
```

Add the non-802.11mc and non-802.11az capable devices specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#` to the list of devices with which to measure range. The total number of peers added to a request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Accurate ranging cannot be supported if the Access Point does not support IEEE 802.11mc and IEEE 802.11az, and instead an alternate protocol called one-sided RTT will be used with lower accuracy. Use `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()` to verify the Access Point(s) are not 802.11mc capable. Use `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` ()} to verify the Access Point(s) are not 802.11az capable.

One-sided RTT does not subtract the RTT turnaround time at the Access Point, which can add hundreds of meters to the estimate. With experimentation, it is possible to use this information to make a statistical estimate of the range by taking multiple measurements to several Access Points and normalizing the result. For some applications this can be used to improve range estimates based on Receive Signal Strength Indication (RSSI), but will not be as accurate as IEEE 802.11mc (two-sided RTT).

Note: one-sided RTT should only be used if you are very familiar with statistical estimation techniques.

| Parameters ||
|---|---|
| `apInfos` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[ScanResult](https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#)!\>: Information about Access Points (APs) obtained in a Scan Result. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addResponder

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

```
fun addResponder(responder: ResponderConfig): RangingRequest.Builder
```

Add the Responder device specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig` to the list of devices with which to measure range. The total number of peers added to the request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Two-sided Ranging will be performed if the local device and the AP support IEEE 802.11az (non-trigger based ranging) or IEEE 802.11mc. AP capability is determined by the method `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` or `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()`. If both 11az and 11mc are supported by the local device and the AP, 11az non-trigger based ranging will be performed. If two-sided ranging is not supported, one-sided RTT will be performed with no correction for the AP packet turnaround time.

| Parameters ||
|---|---|
| `responder` | [ResponderConfig](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig): Information on the RTT Responder. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder, to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addResponders

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

```
fun addResponders(responders: MutableList<ResponderConfig!>): RangingRequest.Builder
```

Add the devices specified by the `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig`s to the list of devices with which to measure range. The total number of peers added to a request cannot exceed the limit specified by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxPeers()`.

Two-sided Ranging will be performed if the local device and the AP support IEEE 802.11az (non-trigger based ranging) or IEEE 802.11mc. AP capability is determined by the method `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211azNtbResponder()` or `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#is80211mcResponder()`. If both 11az and 11mc are supported by the local device and the AP, 11az non-trigger based ranging will be performed. If two-sided ranging is not supported, one-sided RTT will be performed with no correction for the AP packet turnaround time.

| Parameters ||
|---|---|
| `responders` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[ResponderConfig](https://developer.android.com/reference/kotlin/android/net/wifi/rtt/ResponderConfig)!\>: Information representing the set of access points to be ranged. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### addWifiAwarePeer

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

```
fun addWifiAwarePeer(peerMacAddress: MacAddress): RangingRequest.Builder!
```

Add the device specified by the `peerMacAddress` to the list of devices with which to measure range.

The MAC address may be obtained out-of-band from a peer Wi-Fi Aware device. A Wi-Fi Aware device may obtain its MAC address using the `https://developer.android.com/reference/kotlin/android/net/wifi/aware/IdentityChangedListener.html#` provided to `https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareManager.html#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)`.

Note: in order to use this API the device must support Wi-Fi Aware `https://developer.android.com/reference/kotlin/android/net/wifi/aware/package-summary.html`. The peer device which is being ranged to must be configured to publish a service (with any name) with:
- Type `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.html#PUBLISH_TYPE_UNSOLICITED:kotlin.Int`.
- Ranging enabled `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder.html#setRangingEnabled(kotlin.Boolean)`.

| Parameters ||
|---|---|
| `peerMacAddress` | [MacAddress](https://developer.android.com/reference/kotlin/android/net/MacAddress.html#): The MAC address of the Wi-Fi Aware peer. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#!` | The builder, to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### addWifiAwarePeer

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

```
fun addWifiAwarePeer(peerHandle: PeerHandle): RangingRequest.Builder!
```

Add a device specified by a `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PeerHandle.html#` to the list of devices with which to measure range.

The `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PeerHandle.html#` may be obtained as part of the Wi-Fi Aware discovery process. E.g. using `https://developer.android.com/reference/kotlin/android/net/wifi/aware/DiscoverySessionCallback.html#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20kotlin.ByteArray,%20kotlin.collections.MutableList)`.

Note: in order to use this API the device must support Wi-Fi Aware `https://developer.android.com/reference/kotlin/android/net/wifi/aware/package-summary.html`. The requesting device can be either publisher or subscriber in a discovery session. For both requesting device and peer device ranging must be enabled on the discovery session:
- `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder.html#setRangingEnabled(kotlin.Boolean)` for publisher.
- `https://developer.android.com/reference/kotlin/android/net/wifi/aware/SubscribeConfig.Builder.html#setEgressDistanceMm(kotlin.Int)` or `https://developer.android.com/reference/kotlin/android/net/wifi/aware/SubscribeConfig.Builder.html#setIngressDistanceMm(kotlin.Int)` must be set to enable ranging on subscriber

| Parameters ||
|---|---|
| `peerHandle` | [PeerHandle](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PeerHandle.html#): The peer handler of the peer Wi-Fi Aware device. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#!` | The builder, to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### build

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

```
fun build(): RangingRequest!
```

Build `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest` given the current configurations made on the builder.

### setRttBurstSize

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

```
fun setRttBurstSize(rttBurstSize: Int): RangingRequest.Builder
```

Set the RTT Burst size for the ranging request.

If not set, the default RTT burst size given by `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getDefaultRttBurstSize()` is used to determine the default value. If set, the value must be in the range `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMinRttBurstSize()` and `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#getMaxRttBurstSize()` inclusively, or a `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` will be thrown. Note: RTT burst size is primarily applicable to IEEE 802.11mc, but it can also be used with IEEE 802.11az to generate multiple NTB ranging requests per measurement. This is used when multiple very rapid range measurements are needed to improve accuracy during motion, without the overhead of a new application level ranging request.

| Parameters ||
|---|---|
| `rttBurstSize` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The number of FTM packets, or NTB repetitions, used to estimate a range. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |

### setSecurityMode

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

```
fun setSecurityMode(securityMode: Int): RangingRequest.Builder
```

Sets the overall security mode for ranging, determining if secure ranging is attempted with each responder and if fallback to unauthenticated secure ranging is permitted. The mode also permits retry with no security when secure ranging fails. If not set, default mode will be `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#SECURITY_MODE_OPPORTUNISTIC:kotlin.Int`.

See `SECURITY_MODE_*` for different modes of operation.

| Parameters ||
|---|---|
| `securityMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): security mode for ranging. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#SECURITY_MODE_OPEN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#SECURITY_MODE_OPPORTUNISTIC:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest#SECURITY_MODE_SECURE_AUTH:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/RangingRequest.Builder#` | The builder, to facilitate chaining `builder.setXXX(..).setXXX(..)`. This value cannot be `null`. |