Most visited

Recently visited

Added in API level 21

ScanFilter.Builder

public static final class ScanFilter.Builder
extends Object

java.lang.Object
   ↳ android.bluetooth.le.ScanFilter.Builder


Builder类为 ScanFilter

Summary

Public constructors

ScanFilter.Builder()

Public methods

ScanFilter build()

建立 ScanFilter

ScanFilter.Builder setDeviceAddress(String deviceAddress)

在设备地址上设置过滤器。

ScanFilter.Builder setDeviceName(String deviceName)

在设备名称上设置过滤器。

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

在manufacturerData上设置过滤器。

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

在部分制造数据上设置过滤器。

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

在服务数据上设置过滤。

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

在服务数据上设置部分过滤器。

ScanFilter.Builder setServiceUuid(ParcelUuid serviceUuid, ParcelUuid uuidMask)

在部分服务uuid上设置过滤器。

ScanFilter.Builder setServiceUuid(ParcelUuid serviceUuid)

在服务uuid上设置过滤器。

Inherited methods

From class java.lang.Object

Public constructors

ScanFilter.Builder

Added in API level 21
ScanFilter.Builder ()

Public methods

build

Added in API level 21
ScanFilter build ()

建立 ScanFilter

Returns
ScanFilter
Throws
IllegalArgumentException If the filter cannot be built.

setDeviceAddress

Added in API level 21
ScanFilter.Builder setDeviceAddress (String deviceAddress)

在设备地址上设置过滤器。

Parameters
deviceAddress String: The device Bluetooth address for the filter. It needs to be in the format of "01:02:03:AB:CD:EF". The device address can be validated using checkBluetoothAddress(String).
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If the deviceAddress is invalid.

setDeviceName

Added in API level 21
ScanFilter.Builder setDeviceName (String deviceName)

在设备名称上设置过滤器。

Parameters
deviceName String
Returns
ScanFilter.Builder

setManufacturerData

Added in API level 21
ScanFilter.Builder setManufacturerData (int manufacturerId, 
                byte[] manufacturerData)

在manufacturerData上设置过滤器。 负的manufacturerId被视为无效的ID。

请注意, manufacturerData的前两个字节是manufacturerId。

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

setManufacturerData

Added in API level 21
ScanFilter.Builder setManufacturerData (int manufacturerId, 
                byte[] manufacturerData, 
                byte[] manufacturerDataMask)

在部分制造数据上设置过滤器。 对于掩码中的任何位,如果它需要与制造商数据中的匹配,则将其设置为1,否则将其设置为0。

manufacturerDataMask必须具有相同的长度 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.

setServiceData

Added in API level 21
ScanFilter.Builder setServiceData (ParcelUuid serviceDataUuid, 
                byte[] serviceData)

在服务数据上设置过滤。

Parameters
serviceDataUuid ParcelUuid
serviceData byte
Returns
ScanFilter.Builder
Throws
IllegalArgumentException If serviceDataUuid is null.

setServiceData

Added in API level 21
ScanFilter.Builder setServiceData (ParcelUuid serviceDataUuid, 
                byte[] serviceData, 
                byte[] serviceDataMask)

在服务数据上设置部分过滤器。 对于掩码中的任何位,如果需要匹配服务数据中的位,则将其设置为1,否则将其设置为0以忽略该位。

serviceDataMask必须具有相同长度 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.

setServiceUuid

Added in API level 21
ScanFilter.Builder setServiceUuid (ParcelUuid serviceUuid, 
                ParcelUuid uuidMask)

在部分服务uuid上设置过滤器。 uuidMask对于位掩码serviceUuid 将掩码中的任何位设置为1表示serviceUuid的位需要匹配,0表示忽略该位。

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

setServiceUuid

Added in API level 21
ScanFilter.Builder setServiceUuid (ParcelUuid serviceUuid)

在服务uuid上设置过滤器。

Parameters
serviceUuid ParcelUuid
Returns
ScanFilter.Builder

Hooray!