AdvertiseSettings.Builder


public static final class AdvertiseSettings.Builder
extends Object

java.lang.Object
   ↳ android.bluetooth.le.AdvertiseSettings.Builder


Builder class for AdvertiseSettings.

Summary

Public constructors

Builder()

Public methods

AdvertiseSettings build()

Build the AdvertiseSettings object.

AdvertiseSettings.Builder setAdvertiseMode(int advertiseMode)

Set advertise mode to control the advertising power and latency.

AdvertiseSettings.Builder setConnectable(boolean connectable)

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

AdvertiseSettings.Builder setDiscoverable(boolean discoverable)

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

AdvertiseSettings.Builder setTimeout(int timeoutMillis)

Limit advertising to a given amount of time.

AdvertiseSettings.Builder setTxPowerLevel(int txPowerLevel)

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

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

Added in API level 21
public Builder ()

Public methods

build

Added in API level 21
public AdvertiseSettings build ()

Build the AdvertiseSettings object.

setAdvertiseMode

Added in API level 21
public AdvertiseSettings.Builder setAdvertiseMode (int advertiseMode)

Set advertise mode to control the advertising power and latency.

Parameters
advertiseMode int: Bluetooth LE Advertising mode, can only be one of AdvertiseSettings.ADVERTISE_MODE_LOW_POWER, AdvertiseSettings.ADVERTISE_MODE_BALANCED, or AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY.

Throws
IllegalArgumentException If the advertiseMode is invalid.

setConnectable

Added in API level 21
public AdvertiseSettings.Builder setConnectable (boolean connectable)

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
public AdvertiseSettings.Builder setDiscoverable (boolean discoverable)

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).

Returns
AdvertiseSettings.Builder This value cannot be null.

setTimeout

Added in API level 21
public AdvertiseSettings.Builder setTimeout (int timeoutMillis)

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.

Throws
IllegalArgumentException If the provided timeout is over 180000 ms.

setTxPowerLevel

Added in API level 21
public AdvertiseSettings.Builder setTxPowerLevel (int txPowerLevel)

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

Throws
IllegalArgumentException If the txPowerLevel is invalid.