bluetoothIsEnabled
Determine if the bluetooth connector is enabled.
📝 Permissions needed in the manifest
<uses-permission android:name="android.permission.BLUETOOTH" />
Content copied to clipboard
🔑 Minimum required license level: Core.
Sample usage
try {
val networkDiagnostic = rasp.diagnostic.network
val bluetoothIsEnabled = networkDiagnostic.bluetoothIsEnabled()
Log.d("RASP-DEMO", "[networkDiagnostic] bluetoothIsEnabled: $bluetoothIsEnabled")
} catch (e: Exception) {
Log.e("RASP-DEMO", "[networkDiagnostic] bluetoothIsEnabled error: ${e.message}")
}
Content copied to clipboard
To observe changes of the bluetooth check you can use the observe() method.
val modelNetwork = rasp.watcher.network.observe()
launch {
networkModel.bluetoothIsEnabled.collect { detected ->
if (detected != null && detected) {
Log.d("Watcher", "bluetooth value: $detected")
}
}
Content copied to clipboard
Return
Boolean
— true if the bluetooth is currently detected.
Since
v1.3.1