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

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

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

Returns a hash code value for the object.

Boolean

Returns true if this object represents connectable scan result.

Boolean

Returns true if this object represents legacy scan result.

String

Returns a string representation of the object.

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

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

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

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 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, 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 ScanResult.TX_POWER_NOT_PRESENT indicates that the TX power is not present.

hashCode

Added in API level 21
fun hashCode(): Int

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
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

Returns a string representation of the object.

Return
String a string representation of the object.

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

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 the following:

Properties

CREATOR

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