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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

Builder class for `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters`.

## Summary

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

| Public methods ||
|---|---|
| [AdvertisingSetParameters](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#build()()` Build the `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters` object. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setAnonymous(kotlin.Boolean)(isAnonymous: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether advertiser address should be omitted from all packets. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setConnectable(kotlin.Boolean)(connectable: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether the advertisement type should be connectable or non-connectable. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setDiscoverable(kotlin.Boolean)(discoverable: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether the advertisement type should be discoverable or non-discoverable. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setIncludeTxPower(kotlin.Boolean)(includeTxPower: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether TX power should be included in the extended header. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setInterval(kotlin.Int)(interval: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set advertising interval. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setLegacyMode(kotlin.Boolean)(isLegacy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` When set to true, advertising set will advertise 4. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setPrimaryPhy(kotlin.Int)(primaryPhy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the primary physical channel used for this advertising set. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setScannable(kotlin.Boolean)(scannable: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether the advertisement type should be scannable. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setSecondaryPhy(kotlin.Int)(secondaryPhy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the secondary physical channel used for this advertising set. |
| [AdvertisingSetParameters.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#)! | `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters.Builder#setTxPowerLevel(kotlin.Int)(txPowerLevel: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the transmission power level for the advertising. |

## Public constructors

### Builder

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

```
Builder()
```

## Public methods

### build

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

```
fun build(): AdvertisingSetParameters!
```

Build the `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters` object.

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | if invalid combination of parameters is used. |

### setAnonymous

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

```
fun setAnonymous(isAnonymous: Boolean): AdvertisingSetParameters.Builder!
```

Set whether advertiser address should be omitted from all packets. If this mode is used, periodic advertising can't be enabled for this set.

This is used only if legacy mode is not used.

| Parameters ||
|---|---|
| `isAnonymous` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether anonymous advertising should be used. |

### setConnectable

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

```
fun setConnectable(connectable: Boolean): AdvertisingSetParameters.Builder!
```

Set whether the advertisement type should be connectable or non-connectable. Legacy advertisements can be both connectable and scannable. Non-legacy advertisements can be only scannable or only connectable.

| Parameters ||
|---|---|
| `connectable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Controls whether the advertisement type will be connectable (true) or non-connectable (false). |

### setDiscoverable

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

```
fun setDiscoverable(discoverable: Boolean): AdvertisingSetParameters.Builder
```

Set whether the advertisement type should be discoverable or non-discoverable. By default, advertisements will be discoverable. Devices connecting to non-discoverable advertisements cannot initiate bonding.

| Parameters ||
|---|---|
| `discoverable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Controls whether the advertisement type will be discoverable (`true`) or non-discoverable (`false`). |

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

### setIncludeTxPower

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

```
fun setIncludeTxPower(includeTxPower: Boolean): AdvertisingSetParameters.Builder!
```

Set whether TX power should be included in the extended header.

This is used only if legacy mode is not used.

| Parameters ||
|---|---|
| `includeTxPower` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether TX power should be included in extended header |

### setInterval

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

```
fun setInterval(interval: Int): AdvertisingSetParameters.Builder!
```

Set advertising interval.

| Parameters ||
|---|---|
| `interval` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Bluetooth LE Advertising interval, in 0.625ms unit. Valid range is from 160 (100ms) to 16777215 (10,485.759375 s). Recommended values are: `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#INTERVAL_LOW:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#INTERVAL_MEDIUM:kotlin.Int`, or `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#INTERVAL_HIGH:kotlin.Int`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the interval is invalid. |

### setLegacyMode

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

```
fun setLegacyMode(isLegacy: Boolean): AdvertisingSetParameters.Builder!
```

When set to true, advertising set will advertise 4.x Spec compliant advertisements.

| Parameters ||
|---|---|
| `isLegacy` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether legacy advertising mode should be used. |

### setPrimaryPhy

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

```
fun setPrimaryPhy(primaryPhy: Int): AdvertisingSetParameters.Builder!
```

Set the primary physical channel used for this advertising set.

This is used only if legacy mode is not used.

Use `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothAdapter.html#isLeCodedPhySupported()` to determine if LE Coded PHY is supported on this device.

| Parameters ||
|---|---|
| `primaryPhy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Primary advertising physical channel, can only be `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothDevice.html#PHY_LE_1M:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothDevice.html#PHY_LE_CODED:kotlin.Int`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the primaryPhy is invalid. |

### setScannable

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

```
fun setScannable(scannable: Boolean): AdvertisingSetParameters.Builder!
```

Set whether the advertisement type should be scannable. Legacy advertisements can be both connectable and scannable. Non-legacy advertisements can be only scannable or only connectable.

| Parameters ||
|---|---|
| `scannable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Controls whether the advertisement type will be scannable (true) or non-scannable (false). |

### setSecondaryPhy

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

```
fun setSecondaryPhy(secondaryPhy: Int): AdvertisingSetParameters.Builder!
```

Set the secondary physical channel used for this advertising set.

This is used only if legacy mode is not used.

Use `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothAdapter.html#isLeCodedPhySupported()` and `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothAdapter.html#isLe2MPhySupported()` to determine if LE Coded PHY or 2M PHY is supported on this device.

| Parameters ||
|---|---|
| `secondaryPhy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Secondary advertising physical channel, can only be one of `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothDevice.html#PHY_LE_1M:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothDevice.html#PHY_LE_2M:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothDevice.html#PHY_LE_CODED:kotlin.Int`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the secondaryPhy is invalid. |

### setTxPowerLevel

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

```
fun setTxPowerLevel(txPowerLevel: Int): AdvertisingSetParameters.Builder!
```

Set the transmission power level for the advertising.

| Parameters ||
|---|---|
| `txPowerLevel` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Transmission power of Bluetooth LE Advertising, in dBm. The valid range is \[-127, 20\] Recommended values are: `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#TX_POWER_ULTRA_LOW:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#TX_POWER_LOW:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#TX_POWER_MEDIUM:kotlin.Int`, or `https://developer.android.com/reference/kotlin/android/bluetooth/le/AdvertisingSetParameters#TX_POWER_HIGH:kotlin.Int`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the `txPowerLevel` is invalid. |