FileDocCategorySizeDatePackage
ScanResult.javaAPI DocAndroid 5.1 API4729Thu Mar 12 22:22:10 GMT 2015android.bluetooth.le

ScanResult

public final class ScanResult extends Object implements android.os.Parcelable
ScanResult for Bluetooth LE scan.

Fields Summary
private android.bluetooth.BluetoothDevice
mDevice
private ScanRecord
mScanRecord
private int
mRssi
private long
mTimestampNanos
public static final Parcelable.Creator
CREATOR
Constructors Summary
public ScanResult(android.bluetooth.BluetoothDevice device, ScanRecord scanRecord, int rssi, long timestampNanos)
Constructor of scan result.

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

        mDevice = device;
        mScanRecord = scanRecord;
        mRssi = rssi;
        mTimestampNanos = timestampNanos;
    
private ScanResult(android.os.Parcel in)

        readFromParcel(in);
    
Methods Summary
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        ScanResult other = (ScanResult) obj;
        return Objects.equals(mDevice, other.mDevice) && (mRssi == other.mRssi) &&
                Objects.equals(mScanRecord, other.mScanRecord)
                && (mTimestampNanos == other.mTimestampNanos);
    
public android.bluetooth.BluetoothDevicegetDevice()
Returns the remote bluetooth device identified by the bluetooth device address.

        return mDevice;
    
public intgetRssi()
Returns the received signal strength in dBm. The valid range is [-127, 127].

        return mRssi;
    
public ScanRecordgetScanRecord()
Returns the scan record, which is a combination of advertisement and scan response.

        return mScanRecord;
    
public longgetTimestampNanos()
Returns timestamp since boot when the scan record was observed.

        return mTimestampNanos;
    
public inthashCode()

        return Objects.hash(mDevice, mRssi, mScanRecord, mTimestampNanos);
    
private voidreadFromParcel(android.os.Parcel in)

        if (in.readInt() == 1) {
            mDevice = BluetoothDevice.CREATOR.createFromParcel(in);
        }
        if (in.readInt() == 1) {
            mScanRecord = ScanRecord.parseFromBytes(in.createByteArray());
        }
        mRssi = in.readInt();
        mTimestampNanos = in.readLong();
    
public java.lang.StringtoString()

        return "ScanResult{" + "mDevice=" + mDevice + ", mScanRecord="
                + Objects.toString(mScanRecord) + ", mRssi=" + mRssi + ", mTimestampNanos="
                + mTimestampNanos + '}";
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        if (mDevice != null) {
            dest.writeInt(1);
            mDevice.writeToParcel(dest, flags);
        } else {
            dest.writeInt(0);
        }
        if (mScanRecord != null) {
            dest.writeInt(1);
            dest.writeByteArray(mScanRecord.getBytes());
        } else {
            dest.writeInt(0);
        }
        dest.writeInt(mRssi);
        dest.writeLong(mTimestampNanos);