public final class BluetoothLeScanner extends Object
ScanFilter
. It
can also request different types of callbacks for delivering the result.
Use BluetoothAdapter.getBluetoothLeScanner()
to get an instance of
BluetoothLeScanner
.
Note: Most of the scan methods here require
android.Manifest.permission#BLUETOOTH_ADMIN
permission.
ScanFilter
Constructor and Description |
---|
BluetoothLeScanner(IBluetoothManager bluetoothManager)
Use
BluetoothAdapter.getBluetoothLeScanner() instead. |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up scan clients.
|
void |
flushPendingScanResults(ScanCallback callback)
Flush pending batch scan results stored in Bluetooth controller.
|
void |
startScan(List<ScanFilter> filters,
ScanSettings settings,
ScanCallback callback)
Start Bluetooth LE scan.
|
void |
startScan(ScanCallback callback)
Start Bluetooth LE scan with default parameters and no filters.
|
void |
startScanFromSource(List<ScanFilter> filters,
ScanSettings settings,
WorkSource workSource,
ScanCallback callback)
Start Bluetooth LE scan.
|
void |
startScanFromSource(WorkSource workSource,
ScanCallback callback)
Start Bluetooth LE scan.
|
void |
startTruncatedScan(List<TruncatedFilter> truncatedFilters,
ScanSettings settings,
ScanCallback callback)
Start truncated scan.
|
void |
stopScan(ScanCallback callback)
Stops an ongoing Bluetooth LE scan.
|
public BluetoothLeScanner(IBluetoothManager bluetoothManager)
BluetoothAdapter.getBluetoothLeScanner()
instead.bluetoothManager
- BluetoothManager that conducts overall Bluetooth Management.public void startScan(ScanCallback callback)
callback
.
Requires android.Manifest.permission#BLUETOOTH_ADMIN
permission.
An app must hold
ACCESS_COARSE_LOCATION
or
ACCESS_FINE_LOCATION
permission
in order to get results.
callback
- Callback used to deliver scan results.IllegalArgumentException
- If callback
is null.public void startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
callback
.
Requires android.Manifest.permission#BLUETOOTH_ADMIN
permission.
An app must hold
ACCESS_COARSE_LOCATION
or
ACCESS_FINE_LOCATION
permission
in order to get results.
filters
- ScanFilter
s for finding exact BLE devices.settings
- Settings for the scan.callback
- Callback used to deliver scan results.IllegalArgumentException
- If settings
or callback
is null.public void startScanFromSource(WorkSource workSource, ScanCallback callback)
startScan(ScanCallback)
but allows the caller to
specify on behalf of which application(s) the work is being done.workSource
- WorkSource
identifying the application(s) for which to blame for
the scan.callback
- Callback used to deliver scan results.public void startScanFromSource(List<ScanFilter> filters, ScanSettings settings, WorkSource workSource, ScanCallback callback)
startScan(List, ScanSettings, ScanCallback)
but
allows the caller to specify on behalf of which application(s) the work is being done.filters
- ScanFilter
s for finding exact BLE devices.settings
- Settings for the scan.workSource
- WorkSource
identifying the application(s) for which to blame for
the scan.callback
- Callback used to deliver scan results.public void stopScan(ScanCallback callback)
Requires android.Manifest.permission#BLUETOOTH_ADMIN
permission.
callback
- public void flushPendingScanResults(ScanCallback callback)
callback
.callback
- Callback of the Bluetooth LE Scan, it has to be the same instance as the one
used to start scan.public void startTruncatedScan(List<TruncatedFilter> truncatedFilters, ScanSettings settings, ScanCallback callback)
public void cleanup()