FileDocCategorySizeDatePackage
AdvertiseData.javaAPI DocAndroid 5.1 API11765Thu Mar 12 22:22:10 GMT 2015android.bluetooth.le

AdvertiseData

public final class AdvertiseData extends Object implements android.os.Parcelable
Advertise data packet container for Bluetooth LE advertising. This represents the data to be advertised as well as the scan response data for active scans.

Use {@link AdvertiseData.Builder} to create an instance of {@link AdvertiseData} to be advertised.

see
BluetoothLeAdvertiser
see
ScanRecord

Fields Summary
private final List
mServiceUuids
private final android.util.SparseArray
mManufacturerSpecificData
private final Map
mServiceData
private final boolean
mIncludeTxPowerLevel
private final boolean
mIncludeDeviceName
public static final Parcelable.Creator
CREATOR
Constructors Summary
private AdvertiseData(List serviceUuids, android.util.SparseArray manufacturerData, Map serviceData, boolean includeTxPowerLevel, boolean includeDeviceName)

        mServiceUuids = serviceUuids;
        mManufacturerSpecificData = manufacturerData;
        mServiceData = serviceData;
        mIncludeTxPowerLevel = includeTxPowerLevel;
        mIncludeDeviceName = includeDeviceName;
    
Methods Summary
public intdescribeContents()

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

hide

        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        AdvertiseData other = (AdvertiseData) obj;
        return Objects.equals(mServiceUuids, other.mServiceUuids) &&
                BluetoothLeUtils.equals(mManufacturerSpecificData, other.mManufacturerSpecificData) &&
                BluetoothLeUtils.equals(mServiceData, other.mServiceData) &&
                        mIncludeDeviceName == other.mIncludeDeviceName &&
                        mIncludeTxPowerLevel == other.mIncludeTxPowerLevel;
    
public booleangetIncludeDeviceName()
Whether the device name will be included in the advertisement packet.

        return mIncludeDeviceName;
    
public booleangetIncludeTxPowerLevel()
Whether the transmission power level will be included in the advertisement packet.

        return mIncludeTxPowerLevel;
    
public android.util.SparseArraygetManufacturerSpecificData()
Returns an array of manufacturer Id and the corresponding manufacturer specific data. The manufacturer id is a non-negative number assigned by Bluetooth SIG.

        return mManufacturerSpecificData;
    
public java.util.MapgetServiceData()
Returns a map of 16-bit UUID and its corresponding service data.

        return mServiceData;
    
public java.util.ListgetServiceUuids()
Returns a list of service UUIDs within the advertisement that are used to identify the Bluetooth GATT services.

        return mServiceUuids;
    
public inthashCode()

hide

        return Objects.hash(mServiceUuids, mManufacturerSpecificData, mServiceData,
                mIncludeDeviceName, mIncludeTxPowerLevel);
    
public java.lang.StringtoString()

        return "AdvertiseData [mServiceUuids=" + mServiceUuids + ", mManufacturerSpecificData="
                + BluetoothLeUtils.toString(mManufacturerSpecificData) + ", mServiceData="
                + BluetoothLeUtils.toString(mServiceData)
                + ", mIncludeTxPowerLevel=" + mIncludeTxPowerLevel + ", mIncludeDeviceName="
                + mIncludeDeviceName + "]";
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeList(mServiceUuids);

        // mManufacturerSpecificData could not be null.
        dest.writeInt(mManufacturerSpecificData.size());
        for (int i = 0; i < mManufacturerSpecificData.size(); ++i) {
            dest.writeInt(mManufacturerSpecificData.keyAt(i));
            byte[] data = mManufacturerSpecificData.valueAt(i);
            if (data == null) {
                dest.writeInt(0);
            } else {
                dest.writeInt(1);
                dest.writeInt(data.length);
                dest.writeByteArray(data);
            }
        }
        dest.writeInt(mServiceData.size());
        for (ParcelUuid uuid : mServiceData.keySet()) {
            dest.writeParcelable(uuid, flags);
            byte[] data = mServiceData.get(uuid);
            if (data == null) {
                dest.writeInt(0);
            } else {
                dest.writeInt(1);
                dest.writeInt(data.length);
                dest.writeByteArray(data);
            }
        }
        dest.writeByte((byte) (getIncludeTxPowerLevel() ? 1 : 0));
        dest.writeByte((byte) (getIncludeDeviceName() ? 1 : 0));