Ble Permission Exception
class BlePermissionException(message: String, val missingPermissions: List<String> = emptyList(), val gattStatus: Int? = null) : BleException
Exception thrown when required Android permissions for BLE operations are missing.
Starting with Android 12 (API 31), BLE operations require runtime permissions from the android.permission.BLUETOOTH_* family. This exception is thrown when an operation is attempted without the necessary permissions.
Required Permissions
BLUETOOTH_SCAN- Required for scanning (Android 12+)BLUETOOTH_CONNECT- Required for connecting and GATT operations (Android 12+)BLUETOOTH_ADVERTISE- Required for advertising (Android 12+)ACCESS_FINE_LOCATION- Required for scanning on older Android versions
Usage Example
when (error) {
is BlePermissionException -> {
Log.e("BLE", "Missing permissions: ${error.missingPermissions}")
// Request the missing permissions
requestPermissions(error.missingPermissions.toTypedArray())
}
}Content copied to clipboard