Added in API level 26

Builder


class Builder
kotlin.Any
   ↳ android.companion.BluetoothLeDeviceFilter.Builder

Builder for BluetoothLeDeviceFilter

Summary

Public constructors

Public methods
BluetoothLeDeviceFilter

BluetoothLeDeviceFilter.Builder!

BluetoothLeDeviceFilter.Builder
setRawDataFilter(rawDataFilter: ByteArray, rawDataFilterMask: ByteArray?)

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

BluetoothLeDeviceFilter.Builder
setRenameFromBytes(prefix: String, suffix: String, bytesFrom: Int, bytesLength: Int, 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 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(prefix: String, suffix: String, nameFrom: Int, nameLength: Int)

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 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?)

Public constructors

Builder

Builder()

Public methods

build

Added in API level 26
fun build(): BluetoothLeDeviceFilter
Return
BluetoothLeDeviceFilter This value cannot be null.

setNamePattern

Added in API level 26
fun setNamePattern(regex: Pattern?): BluetoothLeDeviceFilter.Builder!
Parameters
regex Pattern?: if set, only devices with name matching the given regular expression will be shown This value may be null.
Return
BluetoothLeDeviceFilter.Builder! self for chaining

setRawDataFilter

Added in API level 26
fun setRawDataFilter(
    rawDataFilter: ByteArray,
    rawDataFilterMask: ByteArray?
): BluetoothLeDeviceFilter.Builder

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

Parameters
rawDataFilter ByteArray: bit values that have to match against advertized data This value cannot be null.
rawDataFilterMask ByteArray?: bits that have to be matched This value may be null.
Return
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setRenameFromBytes

Added in API level 26
fun setRenameFromBytes(
    prefix: String,
    suffix: String,
    bytesFrom: Int,
    bytesLength: Int,
    byteOrder: ByteOrder!
): BluetoothLeDeviceFilter.Builder

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 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)
Return
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setRenameFromName

Added in API level 26
fun setRenameFromName(
    prefix: String,
    suffix: String,
    nameFrom: Int,
    nameLength: Int
): BluetoothLeDeviceFilter.Builder

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 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
Return
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.

setScanFilter

Added in API level 26
fun setScanFilter(scanFilter: ScanFilter?): BluetoothLeDeviceFilter.Builder
Parameters
scanFilter ScanFilter?: a ScanFilter to filter devices by This value may be null.
Return
BluetoothLeDeviceFilter.Builder self for chaining This value cannot be null.