BluetoothLeDeviceFilter.Builder


public static final class BluetoothLeDeviceFilter.Builder
extends Object

java.lang.Object
   ↳ android.companion.BluetoothLeDeviceFilter.Builder


Builder for BluetoothLeDeviceFilter

Summary

Public constructors

Builder()

Public methods

BluetoothLeDeviceFilter build()
BluetoothLeDeviceFilter.Builder setNamePattern(Pattern regex)
BluetoothLeDeviceFilter.Builder setRawDataFilter(byte[] rawDataFilter, byte[] rawDataFilterMask)

Filter devices by raw advertisement data, as obtained by ScanRecord#getBytes

BluetoothLeDeviceFilter.Builder setRenameFromBytes(String prefix, String suffix, int bytesFrom, int bytesLength, ByteOrder byteOrder)

Rename the devices shown in the list, using specific bytes from the raw advertisement data (ScanRecord#getBytes) in hexadecimal format, as well as a custom prefix/suffix around them Note that the prefix length is limited to BluetoothLeDeviceFilter.getRenamePrefixLengthLimit() characters to ensure that there's enough space to display the byte data The range of bytes to be displayed cannot be empty

BluetoothLeDeviceFilter.Builder setRenameFromName(String prefix, String suffix, int nameFrom, int nameLength)

Rename the devices shown in the list, using specific characters from the advertised name, as well as a custom prefix/suffix around them Note that the prefix length is limited to BluetoothLeDeviceFilter.getRenamePrefixLengthLimit() characters to ensure that there's enough space to display the byte data The range of name characters to be displayed cannot be empty

BluetoothLeDeviceFilter.Builder setScanFilter(ScanFilter scanFilter)

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

build

public BluetoothLeDeviceFilter build ()

Returns
BluetoothLeDeviceFilter

setNamePattern

Added in API level 26
public BluetoothLeDeviceFilter.Builder setNamePattern (Pattern regex)

Parameters
regex Pattern: if set, only devices with name matching the given regular expression will be shown This value may be null.

Returns
BluetoothLeDeviceFilter.Builder self for chaining

setRawDataFilter

Added in API level 26
public BluetoothLeDeviceFilter.Builder setRawDataFilter (byte[] rawDataFilter, 
                byte[] rawDataFilterMask)

Filter devices by raw advertisement data, as obtained by ScanRecord#getBytes

Parameters
rawDataFilter byte: bit values that have to match against advertized data This value cannot be null.

rawDataFilterMask byte: bits that have to be matched This value may be null.

Returns
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setRenameFromBytes

Added in API level 26
public BluetoothLeDeviceFilter.Builder setRenameFromBytes (String prefix, 
                String suffix, 
                int bytesFrom, 
                int bytesLength, 
                ByteOrder byteOrder)

Rename the devices shown in the list, using specific bytes from the raw advertisement data (ScanRecord#getBytes) in hexadecimal format, as well as a custom prefix/suffix around them Note that the prefix length is limited to BluetoothLeDeviceFilter.getRenamePrefixLengthLimit() characters to ensure that there's enough space to display the byte data The range of bytes to be displayed cannot be empty

Parameters
prefix String: to be displayed before the byte data This value cannot be null.

suffix String: to be displayed after the byte data This value cannot be null.

bytesFrom int: the start byte index to be displayed (inclusive)

bytesLength int: the number of bytes to be displayed from the given index

byteOrder ByteOrder: whether the given range of bytes is big endian (will be displayed in same order) or little endian (will be flipped before displaying)

Returns
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setRenameFromName

Added in API level 26
public BluetoothLeDeviceFilter.Builder setRenameFromName (String prefix, 
                String suffix, 
                int nameFrom, 
                int nameLength)

Rename the devices shown in the list, using specific characters from the advertised name, as well as a custom prefix/suffix around them Note that the prefix length is limited to BluetoothLeDeviceFilter.getRenamePrefixLengthLimit() characters to ensure that there's enough space to display the byte data The range of name characters to be displayed cannot be empty

Parameters
prefix String: to be displayed before the byte data This value cannot be null.

suffix String: to be displayed after the byte data This value cannot be null.

nameFrom int: the start name character index to be displayed (inclusive)

nameLength int: the number of characters to be displayed from the given index

Returns
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setScanFilter

Added in API level 26
public BluetoothLeDeviceFilter.Builder setScanFilter (ScanFilter scanFilter)

Parameters
scanFilter ScanFilter: a ScanFilter to filter devices by This value may be null.

Returns
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.