Android requires additional permissions declared in the manifest for an app to run a BLE scan since API 23 (6.0 / Marshmallow) and perform a Bluetooth Low Energy connection since API 31 (Android 12). These permissions currently assume scanning is only used when the App is in the foreground, and that the App wants to derive the user's location from Bluetooth Low Energy signal (on API >= 23). Below are a number of additions you can make to your AndroidManifext.xml
for your specific use case.
Bridgefy uses the uses-permission-sdk-23
tag to require location only on APIs >= 23, you can request the required permissions by adding the following to your AndroidManifest.xml
:
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30"
tools:node="replace" />
o
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="32"
tools:node="replace" />
You should add the following to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
android:maxSdkVersion="32" />
If you want to access the user's location in the background on APIs > 30, remove the android:maxSdkVersion
attribute.
API 31 (Android 12) introduced new Bluetooth permissions. Bridgefy uses the android:usesPermissionFlags="neverForLocation"
attribute on the BLUETOOTH_SCAN
permission, which indicates scanning will not be used to derive the user's location, so location permissions are not required. If you need to locate the user with BLE scanning, use this instead, but keep in mind that you will still need ACCESS_FINE_LOCATION
:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:node="replace" />
You add the BLUETOOTH_CONNECT
permission that Bridgefy requests in APIs >= 31:
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Required permissions
A summary of available runtime permissions used for BLE:
from API | to API (inclusive) | Acceptable runtime permissions |
---|---|---|
18 | 22 | (No runtime permissions needed) |
23 | 28 | One of below: |