lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

BluetoothLeDeviceFilter.Builder

public static final class BluetoothLeDeviceFilter.Builder
extends Object

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


Builder for BluetoothLeDeviceFilter

Summary

Public constructors

BluetoothLeDeviceFilter.Builder()

Public methods

BluetoothLeDeviceFilter build()

Builds the instance Once this method is called, this builder should no longer be used.

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)

Protected methods

void checkNotUsed()
void markUsed()

Inherited methods

Public constructors

BluetoothLeDeviceFilter.Builder

added in API level 26
public BluetoothLeDeviceFilter.Builder ()

Public methods

build

added in API level 26
public BluetoothLeDeviceFilter build ()

Builds the instance Once this method is called, this builder should no longer be used. Any subsequent calls to a setter or build() will throw an exception

Returns
BluetoothLeDeviceFilter

This value will never be null.

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 must never be null.

rawDataFilterMask byte: bits that have to be matched

This value may be null.

Returns
BluetoothLeDeviceFilter.Builder self for chaining

This value will never 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 must never be null.

suffix String: to be displayed after the byte data

This value must never 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 will never 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 must never be null.

suffix String: to be displayed after the byte data

This value must never 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 will never 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 will never be null.

Protected methods

checkNotUsed

protected void checkNotUsed ()

markUsed

protected void markUsed ()