Added in API level 21

Builder


class Builder
kotlin.Any
   ↳ android.bluetooth.le.AdvertiseSettings.Builder

Builder class for AdvertiseSettings.

Summary

Public constructors

Public methods
AdvertiseSettings!

Build the AdvertiseSettings object.

AdvertiseSettings.Builder!
setAdvertiseMode(advertiseMode: Int)

Set advertise mode to control the advertising power and latency.

AdvertiseSettings.Builder!
setConnectable(connectable: Boolean)

Set whether the advertisement type should be connectable or non-connectable.

AdvertiseSettings.Builder
setDiscoverable(discoverable: Boolean)

Set whether the advertisement type should be discoverable or non-discoverable.

AdvertiseSettings.Builder!
setTimeout(timeoutMillis: Int)

Limit advertising to a given amount of time.

AdvertiseSettings.Builder!
setTxPowerLevel(txPowerLevel: Int)

Set advertise TX power level to control the transmission power level for the advertising.

Public constructors

Builder

Added in API level 21
Builder()

Public methods

build

Added in API level 21
fun build(): AdvertiseSettings!

Build the AdvertiseSettings object.

setAdvertiseMode

Added in API level 21
fun setAdvertiseMode(advertiseMode: Int): AdvertiseSettings.Builder!

Set advertise mode to control the advertising power and latency.

Parameters
advertiseMode Int: Bluetooth LE Advertising mode, can only be one of android.bluetooth.le.AdvertiseSettings#ADVERTISE_MODE_LOW_POWER, android.bluetooth.le.AdvertiseSettings#ADVERTISE_MODE_BALANCED, or android.bluetooth.le.AdvertiseSettings#ADVERTISE_MODE_LOW_LATENCY.
Exceptions
java.lang.IllegalArgumentException If the advertiseMode is invalid.

setConnectable

Added in API level 21
fun setConnectable(connectable: Boolean): AdvertiseSettings.Builder!

Set whether the advertisement type should be connectable or non-connectable.

Parameters
connectable Boolean: Controls whether the advertisement type will be connectable (true) or non-connectable (false).

setDiscoverable

Added in API level 34
fun setDiscoverable(discoverable: Boolean): AdvertiseSettings.Builder

Set whether the advertisement type should be discoverable or non-discoverable.

Parameters
discoverable Boolean: Controls whether the advertisement type will be discoverable (true) or non-discoverable (false).
Return
AdvertiseSettings.Builder This value cannot be null.

setTimeout

Added in API level 21
fun setTimeout(timeoutMillis: Int): AdvertiseSettings.Builder!

Limit advertising to a given amount of time.

Parameters
timeoutMillis Int: Advertising time limit. May not exceed 180000 milliseconds. A value of 0 will disable the time limit.
Exceptions
java.lang.IllegalArgumentException If the provided timeout is over 180000 ms.

setTxPowerLevel

Added in API level 21
fun setTxPowerLevel(txPowerLevel: Int): AdvertiseSettings.Builder!

Set advertise TX power level to control the transmission power level for the advertising.

Parameters
txPowerLevel Int: Transmission power of Bluetooth LE Advertising, can only be one of AdvertiseSettings#ADVERTISE_TX_POWER_ULTRA_LOW, android.bluetooth.le.AdvertiseSettings#ADVERTISE_TX_POWER_LOW, android.bluetooth.le.AdvertiseSettings#ADVERTISE_TX_POWER_MEDIUM or android.bluetooth.le.AdvertiseSettings#ADVERTISE_TX_POWER_HIGH.
Exceptions
java.lang.IllegalArgumentException If the txPowerLevel is invalid.