Android APIs
public final class

ScanResult

extends Object
implements Parcelable
java.lang.Object
   ↳ android.bluetooth.le.ScanResult

Class Overview

ScanResult for Bluetooth LE scan.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<ScanResult> CREATOR
Public Constructors
ScanResult(BluetoothDevice device, ScanRecord scanRecord, int rssi, long timestampNanos)
Constructor of scan result.
Public Methods
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
boolean equals(Object obj)
Compares this instance with the specified object and indicates if they are equal.
BluetoothDevice getDevice()
Returns the remote bluetooth device identified by the bluetooth device address.
int getRssi()
Returns the received signal strength in dBm.
ScanRecord getScanRecord()
Returns the scan record, which is a combination of advertisement and scan response.
long getTimestampNanos()
Returns timestamp since boot when the scan record was observed.
int hashCode()
Returns an integer hash code for this object.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<ScanResult> CREATOR

Added in API level 21

Public Constructors

public ScanResult (BluetoothDevice device, ScanRecord scanRecord, int rssi, long timestampNanos)

Added in API level 21

Constructor of scan result.

Parameters
device Remote bluetooth device that is found.
scanRecord Scan record including both advertising data and scan response data.
rssi Received signal strength.
timestampNanos Device timestamp when the scan result was observed.

Public Methods

public int describeContents ()

Added in API level 21

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

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public boolean equals (Object obj)

Added in API level 21

Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

The general contract for the equals and hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

Parameters
obj the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public BluetoothDevice getDevice ()

Added in API level 21

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

public int getRssi ()

Added in API level 21

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

public ScanRecord getScanRecord ()

Added in API level 21

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

public long getTimestampNanos ()

Added in API level 21

Returns timestamp since boot when the scan record was observed.

public int hashCode ()

Added in API level 21

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
  • this object's hash code.

public String toString ()

Added in API level 21

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel dest, int flags)

Added in API level 21

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.