Added in API level 21

ScanResult


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

ScanResult for Bluetooth LE scan.

Summary

Constants
static Int

For chained advertisements, indicates that the data contained in this scan result is complete.

static Int

For chained advertisements, indicates that the controller was unable to receive all chained packets and the scan result contains incomplete truncated data.

static Int

Periodic advertising interval is not present in the packet.

static Int

Indicates that the secondary physical layer was not used.

static Int

Advertising Set ID is not present in the packet.

static Int

TX power is not present in the packet.

Inherited constants
Public constructors
ScanResult(device: BluetoothDevice!, scanRecord: ScanRecord!, rssi: Int, timestampNanos: Long)

Constructs a new ScanResult.

ScanResult(device: BluetoothDevice!, eventType: Int, primaryPhy: Int, secondaryPhy: Int, advertisingSid: Int, txPower: Int, rssi: Int, periodicAdvertisingInterval: Int, scanRecord: ScanRecord!, timestampNanos: Long)

Constructs a new ScanResult.

Public methods
Int

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Int

Returns the advertising set id.

Int

Returns the data status.

BluetoothDevice!

Returns the remote Bluetooth device identified by the Bluetooth device address.

Int

Returns the periodic advertising interval in units of 1.

Int

Returns the primary Physical Layer on which this advertisement was received.

Int

Returns the received signal strength in dBm.

ScanRecord?

Returns the scan record, which is a combination of advertisement and scan response.

Int

Returns the secondary Physical Layer on which this advertisement was received.

Long

Returns timestamp since boot when the scan record was observed.

Int

Returns the transmit power in dBm.

Int

Boolean

Returns true if this object represents connectable scan result.

Boolean

Returns true if this object represents legacy scan result.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<ScanResult!>

Constants

DATA_COMPLETE

Added in API level 26
static val DATA_COMPLETE: Int

For chained advertisements, indicates that the data contained in this scan result is complete.

Value: 0

DATA_TRUNCATED

Added in API level 26
static val DATA_TRUNCATED: Int

For chained advertisements, indicates that the controller was unable to receive all chained packets and the scan result contains incomplete truncated data.

Value: 2

PERIODIC_INTERVAL_NOT_PRESENT

Added in API level 26
static val PERIODIC_INTERVAL_NOT_PRESENT: Int

Periodic advertising interval is not present in the packet.

Value: 0

PHY_UNUSED

Added in API level 26
static val PHY_UNUSED: Int

Indicates that the secondary physical layer was not used.

Value: 0

SID_NOT_PRESENT

Added in API level 26
static val SID_NOT_PRESENT: Int

Advertising Set ID is not present in the packet.

Value: 255

TX_POWER_NOT_PRESENT

Added in API level 26
static val TX_POWER_NOT_PRESENT: Int

TX power is not present in the packet.

Value: 127

Public constructors

ScanResult

Added in API level 21
ScanResult(
    device: BluetoothDevice!,
    scanRecord: ScanRecord!,
    rssi: Int,
    timestampNanos: Long)

Deprecated: use ScanResult(android.bluetooth.BluetoothDevice,int,int,int,int,int,int,int,android.bluetooth.le.ScanRecord,long)

Constructs a new ScanResult.

Parameters
device BluetoothDevice!: Remote Bluetooth device found.
scanRecord ScanRecord!: Scan record including both advertising data and scan response data.
rssi Int: Received signal strength.
timestampNanos Long: Timestamp at which the scan result was observed.

ScanResult

Added in API level 26
ScanResult(
    device: BluetoothDevice!,
    eventType: Int,
    primaryPhy: Int,
    secondaryPhy: Int,
    advertisingSid: Int,
    txPower: Int,
    rssi: Int,
    periodicAdvertisingInterval: Int,
    scanRecord: ScanRecord!,
    timestampNanos: Long)

Constructs a new ScanResult.

Parameters
device BluetoothDevice!: Remote Bluetooth device found.
eventType Int: Event type.
primaryPhy Int: Primary advertising phy.
secondaryPhy Int: Secondary advertising phy.
advertisingSid Int: Advertising set ID.
txPower Int: Transmit power.
rssi Int: Received signal strength.
periodicAdvertisingInterval Int: Periodic advertising interval.
scanRecord ScanRecord!: Scan record including both advertising data and scan response data.
timestampNanos Long: Timestamp at which the scan result was observed.

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

equals

Added in API level 21
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getAdvertisingSid

Added in API level 26
fun getAdvertisingSid(): Int

Returns the advertising set id. May return ScanResult#SID_NOT_PRESENT if no set id was is present.

getDataStatus

Added in API level 26
fun getDataStatus(): Int

Returns the data status. Can be one of ScanResult#DATA_COMPLETE or android.bluetooth.le.ScanResult#DATA_TRUNCATED.

getDevice

Added in API level 21
fun getDevice(): BluetoothDevice!

Returns the remote Bluetooth device identified by the Bluetooth device address. If the device is bonded, calling BluetoothDevice#getAddress on the object returned by this method will return the address that was originally bonded with (either identity address or random address).

getPeriodicAdvertisingInterval

Added in API level 26
fun getPeriodicAdvertisingInterval(): Int

Returns the periodic advertising interval in units of 1.25ms. Valid range is 6 (7.5ms) to 65536 (81918.75ms). A value of ScanResult#PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.

getPrimaryPhy

Added in API level 26
fun getPrimaryPhy(): Int

Returns the primary Physical Layer on which this advertisement was received. Can be one of BluetoothDevice#PHY_LE_1M or BluetoothDevice#PHY_LE_CODED.

getRssi

Added in API level 21
fun getRssi(): Int

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

getScanRecord

Added in API level 21
fun getScanRecord(): ScanRecord?

Returns the scan record, which is a combination of advertisement and scan response.

Return
ScanRecord? This value may be null.

getSecondaryPhy

Added in API level 26
fun getSecondaryPhy(): Int

Returns the secondary Physical Layer on which this advertisement was received. Can be one of BluetoothDevice#PHY_LE_1M, BluetoothDevice#PHY_LE_2M, android.bluetooth.BluetoothDevice#PHY_LE_CODED or ScanResult#PHY_UNUSED - if the advertisement was not received on a secondary physical channel.

getTimestampNanos

Added in API level 21
fun getTimestampNanos(): Long

Returns timestamp since boot when the scan record was observed.

getTxPower

Added in API level 26
fun getTxPower(): Int

Returns the transmit power in dBm. Valid range is [-127, 126]. A value of android.bluetooth.le.ScanResult#TX_POWER_NOT_PRESENT indicates that the TX power is not present.

hashCode

Added in API level 21
fun hashCode(): Int
Return
Int a hash code value for this object.

isConnectable

Added in API level 26
fun isConnectable(): Boolean

Returns true if this object represents connectable scan result.

isLegacy

Added in API level 26
fun isLegacy(): Boolean

Returns true if this object represents legacy scan result. Legacy scan results do not contain advanced advertising information as specified in the Bluetooth Core Specification v5.

toString

Added in API level 21
fun toString(): String
Return
String a string representation of the object.

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<ScanResult!>