public final class ScanResult


Represents a scan result for Bluetooth LE scan.

The ScanResult class is used by Bluetooth LE applications to scan for and discover Bluetooth LE devices. When a Bluetooth LE application scans for devices, it will receive a list of ScanResult objects that contain information about the scanned devices. The application can then use this information to determine which devices it wants to connect to.

Summary

Constants

static final int

Periodic advertising interval is not present in the packet.

Public methods

final @NonNull BluetoothDevice

Remote Bluetooth device found.

final @NonNull BluetoothAddress

Bluetooth address for the remote device found.

final byte[]
getManufacturerSpecificData(int manufacturerId)

Returns the manufacturer specific data associated with the manufacturer id.

final long

Returns the periodic advertising interval in milliseconds ranging from 7.5ms to 81918.75ms A value of PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.

final int

Returns the received signal strength in dBm.

final @NonNull Map<@NonNull ParcelUuid, @NonNull byte[]>

Returns a map of service UUID and its corresponding service data.

final byte[]
getServiceData(@NonNull UUID serviceUuid)

Returns the service data associated with the service UUID.

final @NonNull List<@NonNull ParcelUuid>

Returns a list of service solicitation UUIDs within the advertisement that are used to identify the Bluetooth GATT services.

final @NonNull List<@NonNull UUID>

A list of service UUIDs within advertisement that are used to identify the bluetooth GATT services.

final long

Device timestamp when the advertisement was last seen.

final boolean

Checks if this object represents a connectable scan result.

Constants

PERIODIC_INTERVAL_NOT_PRESENT

public static final int PERIODIC_INTERVAL_NOT_PRESENT

Periodic advertising interval is not present in the packet.

Public methods

getDevice

Added in 1.0.0-alpha02
public final @NonNull BluetoothDevice getDevice()

Remote Bluetooth device found.

getDeviceAddress

Added in 1.0.0-alpha02
public final @NonNull BluetoothAddress getDeviceAddress()

Bluetooth address for the remote device found.

getManufacturerSpecificData

Added in 1.0.0-alpha02
public final byte[] getManufacturerSpecificData(int manufacturerId)

Returns the manufacturer specific data associated with the manufacturer id.

Parameters
int manufacturerId

The manufacturer id of the scanned device

Returns
byte[]

the manufacturer specific data associated with the manufacturer id, or @{code null} if the manufacturer specific data is not present

getPeriodicAdvertisingInterval

Added in 1.0.0-alpha02
public final long getPeriodicAdvertisingInterval()

Returns the periodic advertising interval in milliseconds ranging from 7.5ms to 81918.75ms A value of PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.

Please note that this will return PERIODIC_INTERVAL_NOT_PRESENT on versions before android.os.Build.VERSION_CODES.Q.

getRssi

Added in 1.0.0-alpha02
public final int getRssi()

Returns the received signal strength in dBm. The valid range is -127, 126.

getServiceData

Added in 1.0.0-alpha02
public final @NonNull Map<@NonNull ParcelUuid, @NonNull byte[]> getServiceData()

Returns a map of service UUID and its corresponding service data.

getServiceData

Added in 1.0.0-alpha02
public final byte[] getServiceData(@NonNull UUID serviceUuid)

Returns the service data associated with the service UUID.

Parameters
@NonNull UUID serviceUuid

The service UUID of the service data

Returns
byte[]

the service data associated with the specified service UUID, or null if the service UUID is not found

getServiceSolicitationUuids

Added in 1.0.0-alpha02
public final @NonNull List<@NonNull ParcelUuidgetServiceSolicitationUuids()

Returns a list of service solicitation UUIDs within the advertisement that are used to identify the Bluetooth GATT services.

Please note that this will return an emptyList() on versions before android.os.Build.VERSION_CODES.Q.

getServiceUuids

Added in 1.0.0-alpha02
public final @NonNull List<@NonNull UUIDgetServiceUuids()

A list of service UUIDs within advertisement that are used to identify the bluetooth GATT services.

getTimestampNanos

Added in 1.0.0-alpha02
public final long getTimestampNanos()

Device timestamp when the advertisement was last seen.

isConnectable

Added in 1.0.0-alpha02
public final boolean isConnectable()

Checks if this object represents a connectable scan result.

Returns
boolean

{@code true} if the scanned device is connectable.

Please note that this will return {@code true} on versions before android.os.Build.VERSION_CODES.Q.