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:

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
}

See also

Functions

Link copied to clipboard

Checks if the app has the necessary permissions to perform BLE advertising.

Link copied to clipboard

Checks if the app has the necessary permissions to perform BLE connections.

Link copied to clipboard
@RequiresApi(value = 31)
fun hasScanPermissions(context: Context): Boolean

Checks if the app has the necessary permissions to perform BLE scanning.