Builder
class Builder
kotlin.Any | |
↳ | android.bluetooth.le.ScanSettings.Builder |
Builder for ScanSettings
.
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
ScanSettings! |
build() Build |
ScanSettings.Builder! |
setCallbackType(callbackType: Int) Set callback type for Bluetooth LE scan. |
ScanSettings.Builder! |
Set whether only legacy advertisements should be returned in scan results. |
ScanSettings.Builder! |
setMatchMode(matchMode: Int) Set match mode for Bluetooth LE scan filters hardware match. |
ScanSettings.Builder! |
setNumOfMatches(numOfMatches: Int) Set the number of matches for Bluetooth LE scan filters hardware match. |
ScanSettings.Builder! |
Set the Physical Layer to use during this scan. |
ScanSettings.Builder! |
setReportDelay(reportDelayMillis: Long) Set report delay timestamp for Bluetooth LE scan. |
ScanSettings.Builder! |
setScanMode(scanMode: Int) Set scan mode for Bluetooth LE scan. |
Public constructors
Public methods
build
fun build(): ScanSettings!
Build ScanSettings
.
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the settings cannot be built. |
setCallbackType
fun setCallbackType(callbackType: Int): ScanSettings.Builder!
Set callback type for Bluetooth LE scan.
Parameters | |
---|---|
callbackType |
Int: The callback type flags for the scan. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the callbackType is invalid. |
setLegacy
fun setLegacy(legacy: Boolean): ScanSettings.Builder!
Set whether only legacy advertisements should be returned in scan results. Legacy advertisements include advertisements as specified by the Bluetooth core specification 4.2 and below. This is true by default for compatibility with older apps.
Parameters | |
---|---|
legacy |
Boolean: true if only legacy advertisements will be returned |
setMatchMode
fun setMatchMode(matchMode: Int): ScanSettings.Builder!
Set match mode for Bluetooth LE scan filters hardware match.
Parameters | |
---|---|
matchMode |
Int: The match mode can be one of ScanSettings.MATCH_MODE_AGGRESSIVE or ScanSettings.MATCH_MODE_STICKY |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the matchMode is invalid. |
setNumOfMatches
fun setNumOfMatches(numOfMatches: Int): ScanSettings.Builder!
Set the number of matches for Bluetooth LE scan filters hardware match.
Parameters | |
---|---|
numOfMatches |
Int: The num of matches can be one of android.bluetooth.le.ScanSettings#MATCH_NUM_ONE_ADVERTISEMENT or android.bluetooth.le.ScanSettings#MATCH_NUM_FEW_ADVERTISEMENT or android.bluetooth.le.ScanSettings#MATCH_NUM_MAX_ADVERTISEMENT |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the matchMode is invalid. |
setPhy
fun setPhy(phy: Int): ScanSettings.Builder!
Set the Physical Layer to use during this scan. This is used only if android.bluetooth.le.ScanSettings.Builder#setLegacy
is set to false. android.bluetooth.BluetoothAdapter#isLeCodedPhySupported
may be used to check whether LE Coded phy is supported by calling android.bluetooth.BluetoothAdapter#isLeCodedPhySupported
. Selecting an unsupported phy will result in failure to start scan.
Parameters | |
---|---|
phy |
Int: Can be one of BluetoothDevice.PHY_LE_1M , android.bluetooth.BluetoothDevice#PHY_LE_CODED or ScanSettings.PHY_LE_ALL_SUPPORTED |
setReportDelay
fun setReportDelay(reportDelayMillis: Long): ScanSettings.Builder!
Set report delay timestamp for Bluetooth LE scan. If set to 0, you will be notified of scan results immediately. If > 0, scan results are queued up and delivered after the requested delay or 5000 milliseconds (whichever is higher). Note scan results may be delivered sooner if the internal buffers fill up.
Parameters | |
---|---|
reportDelayMillis |
Long: how frequently scan results should be delivered in milliseconds |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if reportDelayMillis < 0 |
setScanMode
fun setScanMode(scanMode: Int): ScanSettings.Builder!
Set scan mode for Bluetooth LE scan.
Parameters | |
---|---|
scanMode |
Int: The scan mode can be one of ScanSettings.SCAN_MODE_LOW_POWER , ScanSettings.SCAN_MODE_BALANCED or android.bluetooth.le.ScanSettings#SCAN_MODE_LOW_LATENCY . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the scanMode is invalid. |