Android APIs
public final class

BluetoothLeAdvertiser

extends Object
java.lang.Object
   ↳ android.bluetooth.le.BluetoothLeAdvertiser

Class Overview

This class provides a way to perform Bluetooth LE advertise operations, such as start and stop advertising. An advertiser can broadcast up to 31 bytes of advertisement data represented by AdvertisementData.

To get an instance of BluetoothLeAdvertiser, call the getBluetoothLeAdvertiser() method.

Note most of the methods here require BLUETOOTH_ADMIN permission.

Summary

Public Methods
void startAdvertising(AdvertiseSettings settings, AdvertisementData advertiseData, AdvertiseCallback callback)
Start Bluetooth LE Advertising.
void startAdvertising(AdvertiseSettings settings, AdvertisementData advertiseData, AdvertisementData scanResponse, AdvertiseCallback callback)
Start Bluetooth LE Advertising.
void stopAdvertising(AdvertiseCallback callback)
Stop Bluetooth LE advertising.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void startAdvertising (AdvertiseSettings settings, AdvertisementData advertiseData, AdvertiseCallback callback)

Start Bluetooth LE Advertising. The advertiseData would be broadcasted after the operation succeeds. Returns immediately, the operation status are delivered through callback.

Requires BLUETOOTH_ADMIN permission.

Parameters
settings Settings for Bluetooth LE advertising.
advertiseData Advertisement data to be broadcasted.
callback Callback for advertising status.

public void startAdvertising (AdvertiseSettings settings, AdvertisementData advertiseData, AdvertisementData scanResponse, AdvertiseCallback callback)

Start Bluetooth LE Advertising. The advertiseData would be broadcasted after the operation succeeds. The scanResponse would be returned when the scanning device sends active scan request. Method returns immediately, the operation status are delivered through callback.

Requires BLUETOOTH_ADMIN

Parameters
settings Settings for Bluetooth LE advertising.
advertiseData Advertisement data to be advertised in advertisement packet.
scanResponse Scan response associated with the advertisement data.
callback Callback for advertising status.

public void stopAdvertising (AdvertiseCallback callback)

Stop Bluetooth LE advertising. The callback must be the same one use in startAdvertising(AdvertiseSettings, AdvertisementData, AdvertiseCallback).

Requires BLUETOOTH_ADMIN permission.

Parameters
callback AdvertiseCallback for delivering stopping advertising status.