Added in API level 21

ScanCallback

abstract class ScanCallback
kotlin.Any
   ↳ android.bluetooth.le.ScanCallback

Bluetooth LE scan callbacks. Scan results are reported using these callbacks.

Summary

Constants
static Int

Fails to start scan as BLE scan with the same settings is already started by the app.

static Int

Fails to start scan as app cannot be registered.

static Int

Fails to start power optimized scan as this feature is not supported.

static Int

Fails to start scan due an internal error

static Int

Fails to start scan as it is out of hardware resources.

static Int

Fails to start scan as application tries to scan too frequently.

Public constructors

Public methods
open Unit

Callback when batch results are delivered.

open Unit
onScanFailed(errorCode: Int)

Callback when scan could not be started.

open Unit
onScanResult(callbackType: Int, result: ScanResult!)

Callback when a BLE advertisement has been found.

Constants

SCAN_FAILED_ALREADY_STARTED

Added in API level 21
static val SCAN_FAILED_ALREADY_STARTED: Int

Fails to start scan as BLE scan with the same settings is already started by the app.

Value: 1

SCAN_FAILED_APPLICATION_REGISTRATION_FAILED

Added in API level 21
static val SCAN_FAILED_APPLICATION_REGISTRATION_FAILED: Int

Fails to start scan as app cannot be registered.

Value: 2

SCAN_FAILED_FEATURE_UNSUPPORTED

Added in API level 21
static val SCAN_FAILED_FEATURE_UNSUPPORTED: Int

Fails to start power optimized scan as this feature is not supported.

Value: 4

SCAN_FAILED_INTERNAL_ERROR

Added in API level 21
static val SCAN_FAILED_INTERNAL_ERROR: Int

Fails to start scan due an internal error

Value: 3

SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES

Added in API level 33
static val SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES: Int

Fails to start scan as it is out of hardware resources.

Value: 5

SCAN_FAILED_SCANNING_TOO_FREQUENTLY

Added in API level 33
static val SCAN_FAILED_SCANNING_TOO_FREQUENTLY: Int

Fails to start scan as application tries to scan too frequently.

Value: 6

Public constructors

ScanCallback

Added in API level 21
ScanCallback()

Public methods

onBatchScanResults

Added in API level 21
open fun onBatchScanResults(results: MutableList<ScanResult!>!): Unit

Callback when batch results are delivered.

Parameters
results MutableList<ScanResult!>!: List of scan results that are previously scanned.

onScanResult

Added in API level 21
open fun onScanResult(
    callbackType: Int,
    result: ScanResult!
): Unit

Callback when a BLE advertisement has been found.

Parameters
callbackType Int: Determines how this callback was triggered. Could be one of android.bluetooth.le.ScanSettings#CALLBACK_TYPE_ALL_MATCHES, ScanSettings#CALLBACK_TYPE_FIRST_MATCH or ScanSettings#CALLBACK_TYPE_MATCH_LOST
result ScanResult!: A Bluetooth LE scan result.