Permissions Helper
object PermissionsHelper
Utility object for checking Bluetooth Low Energy (BLE) related permissions.
This helper simplifies the complexity of BLE permission handling across different Android versions. Starting from Android 12 (API 31, codename "S"), new granular Bluetooth permissions were introduced:
Manifest.permission.BLUETOOTH_SCAN - Required for scanning BLE devices
Manifest.permission.BLUETOOTH_CONNECT - Required for connecting to BLE devices
Manifest.permission.BLUETOOTH_ADVERTISE - Required for advertising as a BLE peripheral
On older Android versions (below API 31), Manifest.permission.ACCESS_FINE_LOCATION is typically required for BLE scanning operations.
Usage Example
if (PermissionsHelper.hasScanPermissions(context)) {
// Safe to start BLE scanning
bleScanner.startScan()
} else {
// Request BLUETOOTH_SCAN or ACCESS_FINE_LOCATION permission
}Content copied to clipboard