Android APIs
public static final class

AdvertisementData.Builder

extends Object
java.lang.Object
   ↳ android.bluetooth.le.AdvertisementData.Builder

Class Overview

Builder for AdvertisementData.

Summary

Public Constructors
AdvertisementData.Builder()
Public Methods
AdvertisementData build()
AdvertisementData.Builder setIncludeTxPowerLevel(boolean includeTxPowerLevel)
Whether the transmission power level should be included in the advertising packet.
AdvertisementData.Builder setManufacturerData(int manufacturerId, byte[] manufacturerSpecificData)
Set manufacturer id and data.
AdvertisementData.Builder setServiceData(ParcelUuid serviceDataUuid, byte[] serviceData)
Add service data to advertisement.
AdvertisementData.Builder setServiceUuids(List<ParcelUuid> serviceUuids)
Set the service uuids.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AdvertisementData.Builder ()

Public Methods

public AdvertisementData build ()

Throws
IllegalArgumentException If the data size is larger than 31 bytes.

public AdvertisementData.Builder setIncludeTxPowerLevel (boolean includeTxPowerLevel)

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

public AdvertisementData.Builder setManufacturerData (int manufacturerId, byte[] manufacturerSpecificData)

Set manufacturer id and data. See assigned manufacturer identifies for the existing company identifiers.

Parameters
manufacturerId Manufacturer id assigned by Bluetooth SIG.
manufacturerSpecificData Manufacturer specific data - the first two bytes of the manufacturer specific data are the manufacturer id.
Throws
IllegalArgumentException If the manufacturerId is negative or manufacturerSpecificData is null.

public AdvertisementData.Builder setServiceData (ParcelUuid serviceDataUuid, byte[] serviceData)

Add service data to advertisement.

Parameters
serviceDataUuid A 16 bit uuid of the service data
serviceData Service data - the first two bytes of the service data are the service data uuid.
Throws
IllegalArgumentException If the serviceDataUuid or serviceData is empty.

public AdvertisementData.Builder setServiceUuids (List<ParcelUuid> serviceUuids)

Set the service uuids. Note the corresponding bluetooth Gatt services need to be already added on the device before start BLE advertising.

Parameters
serviceUuids Service uuids to be advertised, could be 16-bit, 32-bit or 128-bit uuids.
Throws
IllegalArgumentException If the serviceUuids are null.