Skip to content

Most visited

Recently visited

navigation

ScanCallback

public abstract class ScanCallback
extends Object

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


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

See also:

Summary

Constants

int SCAN_FAILED_ALREADY_STARTED

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

int SCAN_FAILED_APPLICATION_REGISTRATION_FAILED

Fails to start scan as app cannot be registered.

int SCAN_FAILED_FEATURE_UNSUPPORTED

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

int SCAN_FAILED_INTERNAL_ERROR

Fails to start scan due an internal error

Public constructors

ScanCallback()

Public methods

void onBatchScanResults(List<ScanResult> results)

Callback when batch results are delivered.

void onScanFailed(int errorCode)

Callback when scan could not be started.

void onScanResult(int callbackType, ScanResult result)

Callback when a BLE advertisement has been found.

Inherited methods

From class java.lang.Object

Constants

SCAN_FAILED_ALREADY_STARTED

added in API level 21
int SCAN_FAILED_ALREADY_STARTED

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

Constant Value: 1 (0x00000001)

SCAN_FAILED_APPLICATION_REGISTRATION_FAILED

added in API level 21
int SCAN_FAILED_APPLICATION_REGISTRATION_FAILED

Fails to start scan as app cannot be registered.

Constant Value: 2 (0x00000002)

SCAN_FAILED_FEATURE_UNSUPPORTED

added in API level 21
int SCAN_FAILED_FEATURE_UNSUPPORTED

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

Constant Value: 4 (0x00000004)

SCAN_FAILED_INTERNAL_ERROR

added in API level 21
int SCAN_FAILED_INTERNAL_ERROR

Fails to start scan due an internal error

Constant Value: 3 (0x00000003)

Public constructors

ScanCallback

added in API level 21
ScanCallback ()

Public methods

onBatchScanResults

added in API level 21
void onBatchScanResults (List<ScanResult> results)

Callback when batch results are delivered.

Parameters
results List: List of scan results that are previously scanned.

onScanFailed

added in API level 21
void onScanFailed (int errorCode)

Callback when scan could not be started.

Parameters
errorCode int: Error code (one of SCAN_FAILED_*) for scan failure.

onScanResult

added in API level 21
void onScanResult (int callbackType, 
                ScanResult result)

Callback when a BLE advertisement has been found.

Parameters
callbackType int: Determines how this callback was triggered. Could be one of CALLBACK_TYPE_ALL_MATCHES, CALLBACK_TYPE_FIRST_MATCH or CALLBACK_TYPE_MATCH_LOST

result ScanResult: A Bluetooth LE scan result.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)