public final class BleAdvertiser extends Object
Each BleAdvertiser instance can process only one BLE advertising request.
To start a new BLE advertisement, an application needs to create a new BleAdvertiser instance.
| 构造器 | 说明 |
|---|---|
BleAdvertiser(Context context,
BleAdvertiseCallback callback) |
A constructor used to create a
BleAdvertiser instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
close() |
Closes this advertiser instance and releases the callback instance.
|
void |
startAdvertising(BleAdvertiseSettings settings,
BleAdvertiseData advData,
BleAdvertiseData scanResponse) |
Starts BLE advertising.
|
void |
stopAdvertising() |
Stops BLE advertising.
|
public BleAdvertiser(Context context, BleAdvertiseCallback callback)
BleAdvertiser instance.context - Indicates the context.callback - Indicates the BleAdvertiseCallback instance used to obtain the advertising result.IllegalArgumentException - Throws this exception if callback is null
or the callback is using.public void startAdvertising(BleAdvertiseSettings settings, BleAdvertiseData advData, BleAdvertiseData scanResponse)
settings - Indicates the settings for BLE advertising.advData - Indicates the advertising data.scanResponse - Indicates the scan response associated with the advertising data.IllegalStateException - Throws this exception if the Bluetooth host is not ready for advertising
or this advertiser has been closed.public void stopAdvertising()
public void close()