Builder
class Builder
kotlin.Any | |
↳ | android.bluetooth.le.ScanFilter.Builder |
Builder class for ScanFilter
.
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
ScanFilter! |
build() Build |
ScanFilter.Builder |
setAdvertisingDataType(advertisingDataType: Int) Set filter on advertising data with specific advertising data type. |
ScanFilter.Builder |
setAdvertisingDataTypeWithData(advertisingDataType: Int, advertisingData: ByteArray, advertisingDataMask: ByteArray) Set filter on advertising data with specific advertising data type. |
ScanFilter.Builder! |
setDeviceAddress(deviceAddress: String!) Set a scan filter on the remote device address. |
ScanFilter.Builder! |
setDeviceName(deviceName: String!) Set filter on device name. |
ScanFilter.Builder! |
setManufacturerData(manufacturerId: Int, manufacturerData: ByteArray!) Set filter on on manufacturerData. |
ScanFilter.Builder! |
setManufacturerData(manufacturerId: Int, manufacturerData: ByteArray!, manufacturerDataMask: ByteArray!) Set filter on partial manufacture data. |
ScanFilter.Builder! |
setServiceData(serviceDataUuid: ParcelUuid!, serviceData: ByteArray!) Set filtering on service data. |
ScanFilter.Builder! |
setServiceData(serviceDataUuid: ParcelUuid!, serviceData: ByteArray!, serviceDataMask: ByteArray!) Set partial filter on service data. |
ScanFilter.Builder |
setServiceSolicitationUuid(serviceSolicitationUuid: ParcelUuid?) Set filter on service solicitation uuid. |
ScanFilter.Builder |
setServiceSolicitationUuid(serviceSolicitationUuid: ParcelUuid?, solicitationUuidMask: ParcelUuid?) Set filter on partial service Solicitation uuid. |
ScanFilter.Builder! |
setServiceUuid(serviceUuid: ParcelUuid!) Set filter on service uuid. |
ScanFilter.Builder! |
setServiceUuid(serviceUuid: ParcelUuid!, uuidMask: ParcelUuid!) Set filter on partial service uuid. |
Public constructors
Public methods
build
fun build(): ScanFilter!
Build ScanFilter
.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the filter cannot be built. |
setAdvertisingDataType
fun setAdvertisingDataType(advertisingDataType: Int): ScanFilter.Builder
Set filter on advertising data with specific advertising data type.
The values of advertisingDataType
are assigned by Bluetooth SIG. For more details refer to Bluetooth Generic Access Profile. (https://www.bluetooth.com/specifications/assigned-numbers/)
Return | |
---|---|
ScanFilter.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the advertisingDataType is invalid |
setAdvertisingDataTypeWithData
fun setAdvertisingDataTypeWithData(
advertisingDataType: Int,
advertisingData: ByteArray,
advertisingDataMask: ByteArray
): ScanFilter.Builder
Set filter on advertising data with specific advertising data type. For any bit in the mask, set it the 1 if it needs to match the one in advertising data, otherwise set it to 0.
The values of advertisingDataType
are assigned by Bluetooth SIG. For more details refer to Bluetooth Generic Access Profile. (https://www.bluetooth.com/specifications/assigned-numbers/) The advertisingDataMask
must have the same length of advertisingData
.
Return | |
---|---|
ScanFilter.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the advertisingDataType is invalid, advertisingData or advertisingDataMask is null or advertisingData and advertisingDataMask have different length. |
setDeviceAddress
fun setDeviceAddress(deviceAddress: String!): ScanFilter.Builder!
Set a scan filter on the remote device address.
The address passed to this API must be in big endian byte order. It needs to be in the format of "01:02:03:AB:CD:EF". The device address can be validated using android.bluetooth.BluetoothAdapter#checkBluetoothAddress
. The @AddressType is defaulted to android.bluetooth.BluetoothDevice#ADDRESS_TYPE_PUBLIC
.
Parameters | |
---|---|
deviceAddress |
String!: the remote device Bluetooth address for the filter |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the deviceAddress is invalid |
setDeviceName
fun setDeviceName(deviceName: String!): ScanFilter.Builder!
Set filter on device name.
setManufacturerData
fun setManufacturerData(
manufacturerId: Int,
manufacturerData: ByteArray!
): ScanFilter.Builder!
Set filter on on manufacturerData. A negative manufacturerId is considered as invalid id.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the manufacturerId is invalid. |
setManufacturerData
fun setManufacturerData(
manufacturerId: Int,
manufacturerData: ByteArray!,
manufacturerDataMask: ByteArray!
): ScanFilter.Builder!
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
.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the manufacturerId is invalid, or manufacturerData is null while manufacturerDataMask is not, or manufacturerData and manufacturerDataMask have different length. |
setServiceData
fun setServiceData(
serviceDataUuid: ParcelUuid!,
serviceData: ByteArray!
): ScanFilter.Builder!
Set filtering on service data.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If serviceDataUuid is null. |
setServiceData
fun setServiceData(
serviceDataUuid: ParcelUuid!,
serviceData: ByteArray!,
serviceDataMask: ByteArray!
): ScanFilter.Builder!
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
.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If serviceDataUuid is null or serviceDataMask is null while serviceData is not or serviceDataMask and serviceData has different length. |
setServiceSolicitationUuid
fun setServiceSolicitationUuid(serviceSolicitationUuid: ParcelUuid?): ScanFilter.Builder
Set filter on service solicitation uuid.
Parameters | |
---|---|
serviceSolicitationUuid |
ParcelUuid?: This value may be null . |
Return | |
---|---|
ScanFilter.Builder |
This value cannot be null . |
setServiceSolicitationUuid
fun setServiceSolicitationUuid(
serviceSolicitationUuid: ParcelUuid?,
solicitationUuidMask: ParcelUuid?
): ScanFilter.Builder
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. |
Return | |
---|---|
ScanFilter.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If serviceSolicitationUuid is null but solicitationUuidMask is not null . |
setServiceUuid
fun setServiceUuid(serviceUuid: ParcelUuid!): ScanFilter.Builder!
Set filter on service uuid.
setServiceUuid
fun setServiceUuid(
serviceUuid: ParcelUuid!,
uuidMask: ParcelUuid!
): ScanFilter.Builder!
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.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If serviceUuid is null but uuidMask is not null . |