Added in API level 21

Builder


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

Builder for AdvertiseData.

Summary

Public constructors

Public methods
AdvertiseData.Builder!
addManufacturerData(manufacturerId: Int, manufacturerSpecificData: ByteArray!)

Add manufacturer specific data.

AdvertiseData.Builder!
addServiceData(serviceDataUuid: ParcelUuid!, serviceData: ByteArray!)

Add service data to advertise data.

AdvertiseData.Builder
addServiceSolicitationUuid(serviceSolicitationUuid: ParcelUuid)

Add a service solicitation UUID to advertise data.

AdvertiseData.Builder!
addServiceUuid(serviceUuid: ParcelUuid!)

Add a service UUID to advertise data.

AdvertiseData.Builder

Add Transport Discovery Data to advertise data.

AdvertiseData!

Build the AdvertiseData.

AdvertiseData.Builder!
setIncludeDeviceName(includeDeviceName: Boolean)

Set whether the device name should be included in advertise packet.

AdvertiseData.Builder!
setIncludeTxPowerLevel(includeTxPowerLevel: Boolean)

Whether the transmission power level should be included in the advertise packet.

Public constructors

Builder

Added in API level 21
Builder()

Public methods

addManufacturerData

Added in API level 21
fun addManufacturerData(
    manufacturerId: Int,
    manufacturerSpecificData: ByteArray!
): AdvertiseData.Builder!

Add manufacturer specific data.

Please refer to the Bluetooth Assigned Numbers document provided by the Bluetooth SIG for a list of existing company identifiers.

Parameters
manufacturerId Int: Manufacturer ID assigned by Bluetooth SIG.
manufacturerSpecificData ByteArray!: Manufacturer specific data
Exceptions
java.lang.IllegalArgumentException If the manufacturerId is negative or manufacturerSpecificData is null.

addServiceData

Added in API level 21
fun addServiceData(
    serviceDataUuid: ParcelUuid!,
    serviceData: ByteArray!
): AdvertiseData.Builder!

Add service data to advertise data.

Parameters
serviceDataUuid ParcelUuid!: 16-bit UUID of the service the data is associated with
serviceData ByteArray!: Service data
Exceptions
java.lang.IllegalArgumentException If the serviceDataUuid or serviceData is empty.

addServiceSolicitationUuid

Added in API level 31
fun addServiceSolicitationUuid(serviceSolicitationUuid: ParcelUuid): AdvertiseData.Builder

Add a service solicitation UUID to advertise data.

Parameters
serviceSolicitationUuid ParcelUuid: A service solicitation UUID to be advertised. This value cannot be null.
Return
AdvertiseData.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException If the serviceSolicitationUuid is null.

addServiceUuid

Added in API level 21
fun addServiceUuid(serviceUuid: ParcelUuid!): AdvertiseData.Builder!

Add a service UUID to advertise data.

Parameters
serviceUuid ParcelUuid!: A service UUID to be advertised.
Exceptions
java.lang.IllegalArgumentException If the serviceUuid is null.

addTransportDiscoveryData

Added in API level 33
fun addTransportDiscoveryData(transportDiscoveryData: TransportDiscoveryData): AdvertiseData.Builder

Add Transport Discovery Data to advertise data.

Parameters
transportDiscoveryData TransportDiscoveryData: Transport Discovery Data, consisting of one or more Transport Blocks. Transport Discovery Data AD Type Code is already included. This value cannot be null.
Return
AdvertiseData.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException If the transportDiscoveryData is empty

build

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

Build the AdvertiseData.

setIncludeDeviceName

Added in API level 21
fun setIncludeDeviceName(includeDeviceName: Boolean): AdvertiseData.Builder!

Set whether the device name should be included in advertise packet.

setIncludeTxPowerLevel

Added in API level 21
fun setIncludeTxPowerLevel(includeTxPowerLevel: Boolean): AdvertiseData.Builder!

Whether the transmission power level should be included in the advertise packet. Tx power level field takes 3 bytes in advertise packet.