public final class BluetoothLeAdvertiser extends Object
AdvertiseData
.
To get an instance of BluetoothLeAdvertiser
, call the
BluetoothAdapter.getBluetoothLeAdvertiser()
method.
Note: Most of the methods here require android.Manifest.permission#BLUETOOTH_ADMIN
permission.
AdvertiseData
Constructor and Description |
---|
BluetoothLeAdvertiser(IBluetoothManager bluetoothManager)
Use BluetoothAdapter.getLeAdvertiser() instead.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up advertise clients.
|
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.
|
public BluetoothLeAdvertiser(IBluetoothManager bluetoothManager)
bluetoothManager
- BluetoothManager that conducts overall Bluetooth Managementpublic void startAdvertising(AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseCallback callback)
advertiseData
will be broadcasted.
Returns immediately, the operation status is delivered through callback
.
Requires android.Manifest.permission#BLUETOOTH_ADMIN
permission.
settings
- Settings for Bluetooth LE advertising.advertiseData
- Advertisement data to be broadcasted.callback
- Callback for advertising status.public void startAdvertising(AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseData scanResponse, AdvertiseCallback callback)
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 android.Manifest.permission#BLUETOOTH_ADMIN
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)
callback
must be the same one use in
startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback)
.
Requires android.Manifest.permission#BLUETOOTH_ADMIN
permission.
callback
- AdvertiseCallback
identifies the advertising instance to stop.public void cleanup()