public
final
class
BluetoothLeScanner
extends Object
java.lang.Object | |
↳ | android.bluetooth.le.BluetoothLeScanner |
This class provides methods to perform scan related operations for Bluetooth LE devices. An
application can scan for a particular type of Bluetooth LE devices using ScanFilter
. It
can also request different types of callbacks for delivering the result.
Use getBluetoothLeScanner()
to get an instance of
BluetoothLeScanner
.
Note: Most of the scan methods here require
BLUETOOTH_ADMIN
permission.
See also:
Public methods | |
---|---|
void
|
flushPendingScanResults(ScanCallback callback)
Flush pending batch scan results stored in Bluetooth controller. |
void
|
startScan(ScanCallback callback)
Start Bluetooth LE scan with default parameters and no filters. |
void
|
startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
Start Bluetooth LE scan. |
void
|
stopScan(ScanCallback callback)
Stops an ongoing Bluetooth LE scan. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
void flushPendingScanResults (ScanCallback callback)
Flush pending batch scan results stored in Bluetooth controller. This will return Bluetooth
LE scan results batched on bluetooth controller. Returns immediately, batch scan results data
will be delivered through the callback
.
Parameters | |
---|---|
callback |
ScanCallback :
Callback of the Bluetooth LE Scan, it has to be the same instance as the one
used to start scan.
|
void startScan (ScanCallback callback)
Start Bluetooth LE scan with default parameters and no filters. The scan results will be
delivered through callback
.
Requires BLUETOOTH_ADMIN
permission.
An app must hold
ACCESS_COARSE_LOCATION
or
ACCESS_FINE_LOCATION
permission
in order to get results.
Parameters | |
---|---|
callback |
ScanCallback :
Callback used to deliver scan results. |
Throws | |
---|---|
IllegalArgumentException |
If callback is null.
|
void startScan (List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
Start Bluetooth LE scan. The scan results will be delivered through callback
.
Requires BLUETOOTH_ADMIN
permission.
An app must hold
ACCESS_COARSE_LOCATION
or
ACCESS_FINE_LOCATION
permission
in order to get results.
Parameters | |
---|---|
filters |
List :
ScanFilter s for finding exact BLE devices. |
settings |
ScanSettings :
Settings for the scan. |
callback |
ScanCallback :
Callback used to deliver scan results. |
Throws | |
---|---|
IllegalArgumentException |
If settings or callback is null.
|
void stopScan (ScanCallback callback)
Stops an ongoing Bluetooth LE scan.
Requires BLUETOOTH_ADMIN
permission.