# Print output for @column tags ?> BluetoothLeAdvertiser - Android SDK | Android Developers

Most visited


Recently visited


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 BluetoothAdapter#getBluetoothLeAdvertiser() method.

Note: Most of the methods here require Manifest.permission.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 startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters, AdvertiseData periodicData, int duration, int maxExtendedAdvertisingEvents, AdvertisingSetCallback callback)

Creates a new advertising set.

void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters, AdvertiseData periodicData, int duration, int maxExtendedAdvertisingEvents, AdvertisingSetCallback callback, Handler handler)

Creates a new advertising set.

void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters, AdvertiseData periodicData, AdvertisingSetCallback callback)

Creates a new advertising set.

void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData, AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters, AdvertiseData periodicData, AdvertisingSetCallback callback, Handler handler)

Creates a new advertising set.

void stopAdvertising(AdvertiseCallback callback)

Stop Bluetooth LE advertising.

void stopAdvertisingSet(AdvertisingSetCallback callback)

Used to dispose of a AdvertisingSet object, obtained with BluetoothLeAdvertiser#startAdvertisingSet.

Inherited methods

Public methods


startAdvertising

public 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 Manifest.permission.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

public 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 Manifest.permission.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.

startAdvertisingSet

public void startAdvertisingSet (AdvertisingSetParameters parameters, 
                AdvertiseData advertiseData, 
                AdvertiseData scanResponse, 
                PeriodicAdvertisingParameters periodicParameters, 
                AdvertiseData periodicData, 
                int duration, 
                int maxExtendedAdvertisingEvents, 
                AdvertisingSetCallback callback)

Creates a new advertising set. If operation succeed, device will start advertising. This method returns immediately, the operation status is delivered through callback.onAdvertisingSetStarted().

Parameters
parameters AdvertisingSetParameters: advertising set parameters.

advertiseData AdvertiseData: Advertisement data to be broadcasted. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength. If the advertisement is connectable, three bytes will be added for flags.

scanResponse AdvertiseData: Scan response associated with the advertisement data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

periodicParameters PeriodicAdvertisingParameters: periodic advertisng parameters. If null, periodic advertising will not be started.

periodicData AdvertiseData: Periodic advertising data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

duration int: advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535 (655,350 ms). 0 means advertising should continue until stopped.

maxExtendedAdvertisingEvents int: maximum number of extended advertising events the controller shall attempt to send prior to terminating the extended advertising, even if the duration has not expired. Valid range is from 1 to 255. 0 means no maximum.

callback AdvertisingSetCallback: Callback for advertising set.

Throws
IllegalArgumentException when any of the data parameter exceed the maximum allowable size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising feature is made when it's not supported by the controller.

startAdvertisingSet

public void startAdvertisingSet (AdvertisingSetParameters parameters, 
                AdvertiseData advertiseData, 
                AdvertiseData scanResponse, 
                PeriodicAdvertisingParameters periodicParameters, 
                AdvertiseData periodicData, 
                int duration, 
                int maxExtendedAdvertisingEvents, 
                AdvertisingSetCallback callback, 
                Handler handler)

Creates a new advertising set. If operation succeed, device will start advertising. This method returns immediately, the operation status is delivered through callback.onAdvertisingSetStarted().

Parameters
parameters AdvertisingSetParameters: Advertising set parameters.

advertiseData AdvertiseData: Advertisement data to be broadcasted. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength. If the advertisement is connectable, three bytes will be added for flags.

scanResponse AdvertiseData: Scan response associated with the advertisement data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength

periodicParameters PeriodicAdvertisingParameters: Periodic advertisng parameters. If null, periodic advertising will not be started.

periodicData AdvertiseData: Periodic advertising data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength

duration int: advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535 (655,350 ms). 0 means advertising should continue until stopped.

maxExtendedAdvertisingEvents int: maximum number of extended advertising events the controller shall attempt to send prior to terminating the extended advertising, even if the duration has not expired. Valid range is from 1 to 255. 0 means no maximum.

callback AdvertisingSetCallback: Callback for advertising set.

handler Handler: Thread upon which the callbacks will be invoked.

Throws
IllegalArgumentException When any of the data parameter exceed the maximum allowable size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising feature is made when it's not supported by the controller, or when maxExtendedAdvertisingEvents is used on a controller that doesn't support the LE Extended Advertising

startAdvertisingSet

public void startAdvertisingSet (AdvertisingSetParameters parameters, 
                AdvertiseData advertiseData, 
                AdvertiseData scanResponse, 
                PeriodicAdvertisingParameters periodicParameters, 
                AdvertiseData periodicData, 
                AdvertisingSetCallback callback)

Creates a new advertising set. If operation succeed, device will start advertising. This method returns immediately, the operation status is delivered through callback.onAdvertisingSetStarted().

Parameters
parameters AdvertisingSetParameters: advertising set parameters.

advertiseData AdvertiseData: Advertisement data to be broadcasted. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength. If the advertisement is connectable, three bytes will be added for flags.

scanResponse AdvertiseData: Scan response associated with the advertisement data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

periodicParameters PeriodicAdvertisingParameters: periodic advertisng parameters. If null, periodic advertising will not be started.

periodicData AdvertiseData: Periodic advertising data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

callback AdvertisingSetCallback: Callback for advertising set.

Throws
IllegalArgumentException when any of the data parameter exceed the maximum allowable size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising feature is made when it's not supported by the controller.

startAdvertisingSet

public void startAdvertisingSet (AdvertisingSetParameters parameters, 
                AdvertiseData advertiseData, 
                AdvertiseData scanResponse, 
                PeriodicAdvertisingParameters periodicParameters, 
                AdvertiseData periodicData, 
                AdvertisingSetCallback callback, 
                Handler handler)

Creates a new advertising set. If operation succeed, device will start advertising. This method returns immediately, the operation status is delivered through callback.onAdvertisingSetStarted().

Parameters
parameters AdvertisingSetParameters: advertising set parameters.

advertiseData AdvertiseData: Advertisement data to be broadcasted. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength. If the advertisement is connectable, three bytes will be added for flags.

scanResponse AdvertiseData: Scan response associated with the advertisement data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

periodicParameters PeriodicAdvertisingParameters: periodic advertisng parameters. If null, periodic advertising will not be started.

periodicData AdvertiseData: Periodic advertising data. Size must not exceed BluetoothAdapter#getLeMaximumAdvertisingDataLength.

callback AdvertisingSetCallback: Callback for advertising set.

handler Handler: thread upon which the callbacks will be invoked.

Throws
IllegalArgumentException when any of the data parameter exceed the maximum allowable size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising feature is made when it's not supported by the controller.

stopAdvertising

public void stopAdvertising (AdvertiseCallback callback)

Stop Bluetooth LE advertising. The callback must be the same one use in BluetoothLeAdvertiser#startAdvertising.

Requires Manifest.permission.BLUETOOTH_ADMIN permission.

Parameters
callback AdvertiseCallback: AdvertiseCallback identifies the advertising instance to stop.

stopAdvertisingSet

public void stopAdvertisingSet (AdvertisingSetCallback callback)

Used to dispose of a AdvertisingSet object, obtained with BluetoothLeAdvertiser#startAdvertisingSet.

Parameters
callback AdvertisingSetCallback

Browse this site in English?

You requested a page in English, but your language preference for this site is English.

Would you like to change your language preference and browse this site in English? If you want to change your language preference later, use the language menu at the bottom of each page.