ScanFilter.Builder  |  API reference  |  Android Developers


public static final class ScanFilter.Builder
extends Object



Builder class for ScanFilter.

Summary

Public constructors

Builder()

Public methods

ScanFilter build()

Build ScanFilter.

ScanFilter.Builder setAdvertisingDataType(int advertisingDataType)

Set filter on advertising data with specific advertising data type.

ScanFilter.Builder setAdvertisingDataTypeWithData(int advertisingDataType, byte[] advertisingData, byte[] advertisingDataMask)

Set filter on advertising data with specific advertising data type.

ScanFilter.Builder setDeviceAddress(String deviceAddress)

Set a scan filter on the remote device address.

ScanFilter.Builder setDeviceName(String deviceName)

Set filter on device name.

ScanFilter.Builder setManufacturerData(int manufacturerId, byte[] manufacturerData, byte[] manufacturerDataMask)

Set filter on partial manufacture data.

ScanFilter.Builder setManufacturerData(int manufacturerId, byte[] manufacturerData)

Set filter on on manufacturerData.

ScanFilter.Builder setServiceData(ParcelUuid serviceDataUuid, byte[] serviceData, byte[] serviceDataMask)

Set partial filter on service data.

ScanFilter.Builder setServiceData(ParcelUuid serviceDataUuid, byte[] serviceData)

Set filtering on service data.

ScanFilter.Builder setServiceSolicitationUuid(ParcelUuid serviceSolicitationUuid, ParcelUuid solicitationUuidMask)

Set filter on partial service Solicitation uuid.

ScanFilter.Builder setServiceSolicitationUuid(ParcelUuid serviceSolicitationUuid)

Set filter on service solicitation uuid.

ScanFilter.Builder setServiceUuid(ParcelUuid serviceUuid)

Set filter on service uuid.

ScanFilter.Builder setServiceUuid(ParcelUuid serviceUuid, ParcelUuid uuidMask)

Set filter on partial service uuid.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

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

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

public Builder ()

Public methods

setManufacturerData

public ScanFilter.Builder setManufacturerData (int manufacturerId, 
                byte[] manufacturerData, 
                byte[] manufacturerDataMask)

Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.

The manufacturerDataMask must have the same length of manufacturerData.

Parameters
manufacturerId int
manufacturerData byte
manufacturerDataMask byte
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If the manufacturerId is invalid, or manufacturerData is null while manufacturerDataMask is not, or manufacturerData and manufacturerDataMask have different length.

setManufacturerData

public ScanFilter.Builder setManufacturerData (int manufacturerId, 
                byte[] manufacturerData)

Set filter on on manufacturerData. A negative manufacturerId is considered as invalid id.

Parameters
manufacturerId int
manufacturerData byte
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If the manufacturerId is invalid.

setServiceData

public ScanFilter.Builder setServiceData (ParcelUuid serviceDataUuid, 
                byte[] serviceData, 
                byte[] serviceDataMask)

Set partial filter on service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0 to ignore that bit.

The serviceDataMask must have the same length of the serviceData.

Parameters
serviceDataUuid ParcelUuid
serviceData byte
serviceDataMask byte
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If serviceDataUuid is null or serviceDataMask is null while serviceData is not or serviceDataMask and serviceData has different length.

setServiceSolicitationUuid

public ScanFilter.Builder setServiceSolicitationUuid (ParcelUuid serviceSolicitationUuid, 
                ParcelUuid solicitationUuidMask)

Set filter on partial service Solicitation uuid. The SolicitationUuidMask is the bit mask for the serviceSolicitationUuid. Set any bit in the mask to 1 to indicate a match is needed for the bit in serviceSolicitationUuid, and 0 to ignore that bit.

Parameters
serviceSolicitationUuid ParcelUuid: can only be null if solicitationUuidMask is null.
solicitationUuidMask ParcelUuid: can be null or a mask with no restriction.
Returns
ScanFilter.Builder This value cannot be null.
Throws
IllegalArgumentException If serviceSolicitationUuid is null but solicitationUuidMask is not null.

setServiceSolicitationUuid

public ScanFilter.Builder setServiceSolicitationUuid (ParcelUuid serviceSolicitationUuid)

Set filter on service solicitation uuid.

Parameters
serviceSolicitationUuid ParcelUuid: This value may be null.
Returns
ScanFilter.Builder This value cannot be null.

setServiceUuid

public ScanFilter.Builder setServiceUuid (ParcelUuid serviceUuid, 
                ParcelUuid uuidMask)

Set filter on partial service uuid. The uuidMask is the bit mask for the serviceUuid. Set any bit in the mask to 1 to indicate a match is needed for the bit in serviceUuid, and 0 to ignore that bit.

Parameters
serviceUuid ParcelUuid
uuidMask ParcelUuid
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If serviceUuid is null but uuidMask is not null.