Added in API level 21

ScanSettings


class ScanSettings : Parcelable
kotlin.Any
   ↳ android.bluetooth.le.ScanSettings

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

Summary

Nested classes

Builder for ScanSettings.

Constants
static Long

Minimum report delay for ScanSettings#CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH.

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Use all supported PHYs for scanning.

static Int

Perform Bluetooth LE scan in balanced power mode.

static Int

Scan using highest duty cycle.

static Int

Perform Bluetooth LE scan in low power mode.

static Int

A special Bluetooth LE scan mode.

Inherited constants
Public methods
Int

Int

Boolean

Returns whether only legacy advertisements will be returned.

Int

Returns the physical layer used during a scan.

Long

Returns report delay timestamp based on the device clock.

Int

Int

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<ScanSettings!>

Constants

AUTO_BATCH_MIN_REPORT_DELAY_MILLIS

Added in API level 34
static val AUTO_BATCH_MIN_REPORT_DELAY_MILLIS: Long

Minimum report delay for ScanSettings#CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH.

Value: 600000L

CALLBACK_TYPE_ALL_MATCHES

Added in API level 21
static val CALLBACK_TYPE_ALL_MATCHES: Int

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

Value: 1

CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH

Added in API level 34
static val CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH: Int

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.

Value: 8

CALLBACK_TYPE_FIRST_MATCH

Added in API level 23
static val CALLBACK_TYPE_FIRST_MATCH: Int

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

Value: 2

CALLBACK_TYPE_MATCH_LOST

Added in API level 23
static val CALLBACK_TYPE_MATCH_LOST: Int

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

Value: 4

MATCH_MODE_AGGRESSIVE

Added in API level 23
static val MATCH_MODE_AGGRESSIVE: Int

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

Value: 1

MATCH_MODE_STICKY

Added in API level 23
static val MATCH_MODE_STICKY: Int

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

Value: 2

MATCH_NUM_FEW_ADVERTISEMENT

Added in API level 23
static val MATCH_NUM_FEW_ADVERTISEMENT: Int

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

Value: 2

MATCH_NUM_MAX_ADVERTISEMENT

Added in API level 23
static val MATCH_NUM_MAX_ADVERTISEMENT: Int

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

Value: 3

MATCH_NUM_ONE_ADVERTISEMENT

Added in API level 23
static val MATCH_NUM_ONE_ADVERTISEMENT: Int

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

Value: 1

PHY_LE_ALL_SUPPORTED

Added in API level 26
static val PHY_LE_ALL_SUPPORTED: Int

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.

Value: 255

SCAN_MODE_BALANCED

Added in API level 21
static val SCAN_MODE_BALANCED: Int

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.

Value: 1

SCAN_MODE_LOW_LATENCY

Added in API level 21
static val SCAN_MODE_LOW_LATENCY: Int

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

Value: 2

SCAN_MODE_LOW_POWER

Added in API level 21
static val SCAN_MODE_LOW_POWER: Int

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.

Value: 0

SCAN_MODE_OPPORTUNISTIC

Added in API level 23
static val SCAN_MODE_OPPORTUNISTIC: Int

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

Value: -1

Public methods

describeContents

Added in API level 21
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getCallbackType

Added in API level 21
fun getCallbackType(): Int

getLegacy

Added in API level 26
fun getLegacy(): Boolean

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

getPhy

Added in API level 26
fun getPhy(): Int

Returns the physical layer used during a scan.

getReportDelayMillis

Added in API level 21
fun getReportDelayMillis(): Long

Returns report delay timestamp based on the device clock.

getScanMode

Added in API level 21
fun getScanMode(): Int

getScanResultType

Added in API level 21
fun getScanResultType(): Int

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<ScanSettings!>