Android APIs
public final class

BluetoothLeScanner

extends Object
java.lang.Object
   ↳ android.bluetooth.le.BluetoothLeScanner

Class Overview

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

Summary

Public Methods
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 stopScan(ScanCallback callback)
Stops an ongoing Bluetooth LE scan.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void flushPendingScanResults (ScanCallback callback)

Added in API level 21

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 Callback of the Bluetooth LE Scan, it has to be the same instance as the one used to start scan.

public void startScan (List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)

Added in API level 21

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 ScanFilters for finding exact BLE devices.
settings Settings for the scan.
callback Callback used to deliver scan results.
Throws
IllegalArgumentException If settings or callback is null.

public void startScan (ScanCallback callback)

Added in API level 21

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 Callback used to deliver scan results.
Throws
IllegalArgumentException If callback is null.

public void stopScan (ScanCallback callback)

Added in API level 21

Stops an ongoing Bluetooth LE scan.

Requires BLUETOOTH_ADMIN permission.