Skip to content

Most visited

Recently visited

navigation

BluetoothLeAdvertiser

public final class BluetoothLeAdvertiser
extends Object

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


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

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

Note: Most of the methods here require BLUETOOTH_ADMIN permission.

See also:

Summary

Public methods

void startAdvertising(AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseCallback callback)

Start Bluetooth LE Advertising.

void startAdvertising(AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseCallback callback)

Start Bluetooth LE Advertising.

void stopAdvertising(AdvertiseCallback callback)

Stop Bluetooth LE advertising.

Inherited methods

From class java.lang.Object

Public methods

startAdvertising

added in API level 21
void startAdvertising (AdvertiseSettings settings, 
                AdvertiseData advertiseData, 
                AdvertiseCallback callback)

Start Bluetooth LE Advertising. On success, the advertiseData will be broadcasted. Returns immediately, the operation status is delivered through callback.

Requires BLUETOOTH_ADMIN permission.

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

startAdvertising

added in API level 21
void startAdvertising (AdvertiseSettings settings, 
                AdvertiseData advertiseData, 
                AdvertiseData scanResponse, 
                AdvertiseCallback callback)

Start Bluetooth LE Advertising. The advertiseData will be broadcasted if the operation succeeds. The scanResponse is returned when a scanning device sends an active scan request. This method returns immediately, the operation status is delivered through callback.

Requires BLUETOOTH_ADMIN

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

stopAdvertising

added in API level 21
void stopAdvertising (AdvertiseCallback callback)

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

Requires BLUETOOTH_ADMIN permission.

Parameters
callback AdvertiseCallback: AdvertiseCallback identifies the advertising instance to stop.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.