ScanSettings

public final class ScanSettings
extends Object implements Parcelable

java.lang.Object
   ↳ android.bluetooth.le.ScanSettings


Bluetooth LE scan settings are passed to BluetoothLeScanner#startScan to define the parameters for the scan.

Summary

Nested classes

class ScanSettings.Builder

Builder for ScanSettings

Constants

long AUTO_BATCH_MIN_REPORT_DELAY_MILLIS

Minimum report delay for ScanSettings#CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH.

int CALLBACK_TYPE_ALL_MATCHES

Trigger a callback for every Bluetooth advertisement found that matches the filter criteria.

int CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH

A result callback for every Bluetooth advertisement found that matches the filter criteria is only triggered when screen is turned on.

int CALLBACK_TYPE_FIRST_MATCH

A result callback is only triggered for the first advertisement packet received that matches the filter criteria.

int CALLBACK_TYPE_MATCH_LOST

Receive a callback when advertisements are no longer received from a device that has been previously reported by a first match callback.

int MATCH_MODE_AGGRESSIVE

In Aggressive mode, hw will determine a match sooner even with feeble signal strength and few number of sightings/match in a duration.

int MATCH_MODE_STICKY

For sticky mode, higher threshold of signal strength and sightings is required before reporting by hw.

int MATCH_NUM_FEW_ADVERTISEMENT

Match few advertisement per filter, depends on current capability and availability of the resources in hw.

int MATCH_NUM_MAX_ADVERTISEMENT

Match as many advertisement per filter as hw could allow, depends on current capability and availability of the resources in hw.

int MATCH_NUM_ONE_ADVERTISEMENT

Determines how many advertisements to match per filter, as this is scarce hw resource.

int PHY_LE_ALL_SUPPORTED

Use all supported PHYs for scanning.

int SCAN_MODE_BALANCED

Perform Bluetooth LE scan in balanced power mode.

int SCAN_MODE_LOW_LATENCY

Scan using highest duty cycle.

int SCAN_MODE_LOW_POWER

Perform Bluetooth LE scan in low power mode.

int SCAN_MODE_OPPORTUNISTIC

A special Bluetooth LE scan mode.

Inherited constants

Fields

public static final Creator<ScanSettings> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getCallbackType()
boolean getLegacy()

Returns whether only legacy advertisements will be returned.

int getPhy()

Returns the physical layer used during a scan.

long getReportDelayMillis()

Returns report delay timestamp based on the device clock.

int getScanMode()
int getScanResultType()
void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

AUTO_BATCH_MIN_REPORT_DELAY_MILLIS

Added in API level 34
public static final long AUTO_BATCH_MIN_REPORT_DELAY_MILLIS

Minimum report delay for ScanSettings#CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH.

Constant Value: 600000 (0x00000000000927c0)

CALLBACK_TYPE_ALL_MATCHES

Added in API level 21
public static final int CALLBACK_TYPE_ALL_MATCHES

Trigger a callback for every Bluetooth advertisement found that matches the filter criteria. If no filter is active, all advertisement packets are reported.

Constant Value: 1 (0x00000001)

CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH

Added in API level 34
public static final int CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH

A result callback for every Bluetooth advertisement found that matches the filter criteria is only triggered when screen is turned on. While the screen is turned off, the advertisements are batched and the batched result callbacks are triggered every report delay. When the batch scan with this callback type is activated, the batched result callbacks are also triggered while turning on screen or disabling the scan. This callback type must be used with a report delay of ScanSettings#AUTO_BATCH_MIN_REPORT_DELAY_MILLIS or greater.

Constant Value: 8 (0x00000008)

CALLBACK_TYPE_FIRST_MATCH

Added in API level 23
public static final int CALLBACK_TYPE_FIRST_MATCH

A result callback is only triggered for the first advertisement packet received that matches the filter criteria.

Constant Value: 2 (0x00000002)

CALLBACK_TYPE_MATCH_LOST

Added in API level 23
public static final int CALLBACK_TYPE_MATCH_LOST

Receive a callback when advertisements are no longer received from a device that has been previously reported by a first match callback.

Constant Value: 4 (0x00000004)

MATCH_MODE_AGGRESSIVE

Added in API level 23
public static final int MATCH_MODE_AGGRESSIVE

In Aggressive mode, hw will determine a match sooner even with feeble signal strength and few number of sightings/match in a duration.

Constant Value: 1 (0x00000001)

MATCH_MODE_STICKY

Added in API level 23
public static final int MATCH_MODE_STICKY

For sticky mode, higher threshold of signal strength and sightings is required before reporting by hw.

Constant Value: 2 (0x00000002)

MATCH_NUM_FEW_ADVERTISEMENT

Added in API level 23
public static final int MATCH_NUM_FEW_ADVERTISEMENT

Match few advertisement per filter, depends on current capability and availability of the resources in hw.

Constant Value: 2 (0x00000002)

MATCH_NUM_MAX_ADVERTISEMENT

Added in API level 23
public static final int MATCH_NUM_MAX_ADVERTISEMENT

Match as many advertisement per filter as hw could allow, depends on current capability and availability of the resources in hw.

Constant Value: 3 (0x00000003)

MATCH_NUM_ONE_ADVERTISEMENT

Added in API level 23
public static final int MATCH_NUM_ONE_ADVERTISEMENT

Determines how many advertisements to match per filter, as this is scarce hw resource. Match one advertisement per filter.

Constant Value: 1 (0x00000001)

PHY_LE_ALL_SUPPORTED

Added in API level 26
public static final int PHY_LE_ALL_SUPPORTED

Use all supported PHYs for scanning. This will check the controller capabilities, and start the scan on 1Mbit and LE Coded PHYs if supported, or on the 1Mbit PHY only.

Constant Value: 255 (0x000000ff)

SCAN_MODE_BALANCED

Added in API level 21
public static final int SCAN_MODE_BALANCED

Perform Bluetooth LE scan in balanced power mode. Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.

Constant Value: 1 (0x00000001)

SCAN_MODE_LOW_LATENCY

Added in API level 21
public static final int SCAN_MODE_LOW_LATENCY

Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.

Constant Value: 2 (0x00000002)

SCAN_MODE_LOW_POWER

Added in API level 21
public static final int SCAN_MODE_LOW_POWER

Perform Bluetooth LE scan in low power mode. This is the default scan mode as it consumes the least power. This mode is enforced if the scanning application is not in foreground.

Constant Value: 0 (0x00000000)

SCAN_MODE_OPPORTUNISTIC

Added in API level 23
public static final int SCAN_MODE_OPPORTUNISTIC

A special Bluetooth LE scan mode. Applications using this scan mode will passively listen for other scan results without starting BLE scans themselves.

Constant Value: -1 (0xffffffff)

Fields

CREATOR

Added in API level 21
public static final Creator<ScanSettings> CREATOR

Public methods

describeContents

Added in API level 21
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getCallbackType

Added in API level 21
public int getCallbackType ()

Returns
int

getLegacy

Added in API level 26
public boolean getLegacy ()

Returns whether only legacy advertisements will be returned. Legacy advertisements include advertisements as specified by the Bluetooth core specification 4.2 and below.

Returns
boolean

getPhy

Added in API level 26
public int getPhy ()

Returns the physical layer used during a scan.

Returns
int

getReportDelayMillis

Added in API level 21
public long getReportDelayMillis ()

Returns report delay timestamp based on the device clock.

Returns
long

getScanMode

Added in API level 21
public int getScanMode ()

Returns
int

getScanResultType

Added in API level 21
public int getScanResultType ()

Returns
int

writeToParcel

Added in API level 21
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES