Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#constants) \| [Methods](https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#inhmethods)

# BluetoothLeScanner

*** ** * ** ***


`
public

final

class
BluetoothLeScanner
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.bluetooth.le.BluetoothLeScanner |

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/android/bluetooth/le/ScanFilter`. It
can also request different types of callbacks for delivering the result.

Use `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBluetoothLeScanner()` to get an instance of `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner`.
**See also:**

- `https://developer.android.com/reference/android/bluetooth/le/ScanFilter`

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_CALLBACK_TYPE` Optional extra indicating the callback type, which will be one of CALLBACK_TYPE_\* constants in `https://developer.android.com/reference/android/bluetooth/le/ScanSettings`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_ERROR_CODE` Optional extra indicating the error code, if any. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_LIST_SCAN_RESULT` Extra containing a list of ScanResults. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#flushPendingScanResults(android.bluetooth.le.ScanCallback)(https://developer.android.com/reference/android/bluetooth/le/ScanCallback callback) ` Flush pending batch scan results stored in Bluetooth controller. |
| ` int` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.app.PendingIntent)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/le/ScanFilter> filters, https://developer.android.com/reference/android/bluetooth/le/ScanSettings settings, https://developer.android.com/reference/android/app/PendingIntent callbackIntent) ` Start Bluetooth LE scan using a `https://developer.android.com/reference/android/app/PendingIntent`. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(android.bluetooth.le.ScanCallback)(https://developer.android.com/reference/android/bluetooth/le/ScanCallback callback) ` Start Bluetooth LE scan with default parameters and no filters. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/bluetooth/le/ScanFilter> filters, https://developer.android.com/reference/android/bluetooth/le/ScanSettings settings, https://developer.android.com/reference/android/bluetooth/le/ScanCallback callback) ` Start Bluetooth LE scan. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#stopScan(android.bluetooth.le.ScanCallback)(https://developer.android.com/reference/android/bluetooth/le/ScanCallback callback) ` Stops an ongoing Bluetooth LE scan. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#stopScan(android.app.PendingIntent)(https://developer.android.com/reference/android/app/PendingIntent callbackIntent) ` Stops an ongoing Bluetooth LE scan started using a PendingIntent. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### EXTRA_CALLBACK_TYPE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_CALLBACK_TYPE
```

Optional extra indicating the callback type, which will be one of CALLBACK_TYPE_\* constants
in `https://developer.android.com/reference/android/bluetooth/le/ScanSettings`.

<br />

**See also:**

- `https://developer.android.com/reference/android/bluetooth/le/ScanCallback#onScanResult(int,%20android.bluetooth.le.ScanResult)`

Constant Value:

"android.bluetooth.le.extra.CALLBACK_TYPE"


### EXTRA_ERROR_CODE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_ERROR_CODE
```

Optional extra indicating the error code, if any. The error code will be one of the
SCAN_FAILED_\* codes in `https://developer.android.com/reference/android/bluetooth/le/ScanCallback`.

<br />

Constant Value:

"android.bluetooth.le.extra.ERROR_CODE"


### EXTRA_LIST_SCAN_RESULT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_LIST_SCAN_RESULT
```

Extra containing a list of ScanResults. It can have one or more results if there was no
error. In case of error, `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_ERROR_CODE` will contain the error code and this extra
will not be available.

<br />

Constant Value:

"android.bluetooth.le.extra.LIST_SCAN_RESULT"


## Public methods

### flushPendingScanResults

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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`.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Parameters ||
|---|---|
| `callback` | `ScanCallback`: Callback of the Bluetooth LE Scan, it has to be the same instance as the one used to start scan. <br /> |

### startScan

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int startScan (List<ScanFilter> filters, 
                ScanSettings settings, 
                PendingIntent callbackIntent)
```

Start Bluetooth LE scan using a `https://developer.android.com/reference/android/app/PendingIntent`. The scan results will be delivered via
the PendingIntent. Use this method of scanning if your process is not always running and it
should be started when scan results are available.

An app must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION` permission in order to get results. An App targeting Android Q or
later must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission in order to get results.

When the PendingIntent is delivered, the Intent passed to the receiver or activity will
contain one or more of the extras `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_CALLBACK_TYPE`, `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_ERROR_CODE` and
`https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#EXTRA_LIST_SCAN_RESULT` to indicate the result of the scan.

This method requires the calling app to have the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission. Additionally, an app must have the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` if any of the following is true:

- it is used for BLE scan only mode (when the adapter state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`).
- the `https://developer.android.com/reference/android/bluetooth/le/ScanSettings` uses `https://developer.android.com/`.
- the `https://developer.android.com/reference/android/bluetooth/le/ScanSettings` uses batched scanning (`https://developer.android.com/reference/android/bluetooth/le/ScanSettings#getReportDelayMillis()` \> 0) with `https://developer.android.com/`.
- a `https://developer.android.com/reference/android/bluetooth/le/ScanFilter` has a device address set, and either the address type is not `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_PUBLIC` or the IRK is not null.

.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.   
In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION` permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a strong assertion that you will never derive the physical location of the device, made by declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth devices you can interact with.

<br />

<br />

| Parameters ||
|---|---|
| `filters` | `List`: Optional list of ScanFilters for finding exact BLE devices. This value may be `null`. <br /> |
| `settings` | `ScanSettings`: Optional settings for the scan. This value may be `null`. <br /> |
| `callbackIntent` | `PendingIntent`: The PendingIntent to deliver the result to. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | Returns 0 for success or an error code from `https://developer.android.com/reference/android/bluetooth/le/ScanCallback` if the scan request could not be sent. <br /> |

**See also:**

- `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#stopScan(android.app.PendingIntent)`

### startScan

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void startScan (ScanCallback callback)
```

Start Bluetooth LE scan with default parameters and no filters. The scan results will be
delivered through `callback`. For unfiltered scans, scanning is stopped on screen off
to save power. Scanning is resumed when screen is turned on again. To avoid this, use `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback)` with desired `https://developer.android.com/reference/android/bluetooth/le/ScanFilter`.

An app must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION` permission in order to get results. An App targeting Android Q or
later must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission in order to get results.

This method requires the calling app to have the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission. Additionally, an app must have the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` if it is used for BLE scan only mode
(when the adapter state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`).


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a
strong assertion that you will never derive the physical location of the device, made by
declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth
devices you can interact with.

<br />

| Parameters ||
|---|---|
| `callback` | `ScanCallback`: Callback used to deliver scan results. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `callback` is null. |

### startScan

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Start Bluetooth LE scan. The scan results will be delivered through `callback`. For
unfiltered scans, scanning is stopped on screen off to save power. Scanning is resumed when
screen is turned on again. To avoid this, do filtered scanning by using proper `https://developer.android.com/reference/android/bluetooth/le/ScanFilter`.

An app must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION` permission in order to get results. An App targeting Android Q or
later must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`
permission in order to get results.

This method requires the calling app to have the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission. Additionally, an app must have the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED` if any of the following is true:

- it is used for BLE scan only mode (when the adapter state is not `https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#STATE_ON`).
- the `https://developer.android.com/reference/android/bluetooth/le/ScanSettings` uses `https://developer.android.com/`.
- the `https://developer.android.com/reference/android/bluetooth/le/ScanSettings` uses batched scanning (`https://developer.android.com/reference/android/bluetooth/le/ScanSettings#getReportDelayMillis()` \> 0) with `https://developer.android.com/`.
- a `https://developer.android.com/reference/android/bluetooth/le/ScanFilter` has a device address set, and either the address type is not `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#ADDRESS_TYPE_PUBLIC` or the IRK is not null.

.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.   
For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.   
In addition, this requires the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION` permission. For apps targeting `https://developer.android.com/` or higher, an alternative is a strong assertion that you will never derive the physical location of the device, made by declaring `usesPermissionFlags="neverForLocation"` on the relevant `<uses-permission>` manifest tag. However, this assertion may restrict the types of Bluetooth devices you can interact with.

<br />

<br />

| Parameters ||
|---|---|
| `filters` | `List`: `https://developer.android.com/reference/android/bluetooth/le/ScanFilter`s for finding exact BLE devices. This value may be `null`. <br /> |
| `settings` | `ScanSettings`: Settings for the scan. This value cannot be `null`. <br /> |
| `callback` | `ScanCallback`: Callback used to deliver scan results. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `settings` or `callback` is null. |

### stopScan

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void stopScan (ScanCallback callback)
```

Stops an ongoing Bluetooth LE scan.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Parameters ||
|---|---|
| `callback` | `ScanCallback` <br /> |

### stopScan

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void stopScan (PendingIntent callbackIntent)
```

Stops an ongoing Bluetooth LE scan started using a PendingIntent. When creating the
PendingIntent parameter, please do not use the FLAG_CANCEL_CURRENT flag. Otherwise, the stop
scan may have no effect.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or lower, this requires the `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADMIN` permission which can be gained with a simple `<uses-permission>` manifest tag.


For apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or or higher, this requires the
`https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN` permission which can be gained with `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`.


Requires `https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN`

<br />

| Parameters ||
|---|---|
| `callbackIntent` | `PendingIntent`: The PendingIntent that was used to start the scan. <br /> |

**See also:**

- `https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List<android.bluetooth.le.ScanFilter>,%20android.bluetooth.le.ScanSettings,%20android.app.PendingIntent)`