BLUETOOTH_SCAN with neverForLocation

Bram Yeh
1 min readNov 3, 2023

When the app targets Android 12 (API level 31) or higher, the official document strongly recommends that

If your app doesn’t use Bluetooth scan results to derive physical location, you can make a strong assertion that your app never uses the Bluetooth permissions to derive physical location

<uses-permission android:name=”android.permission.BLUETOOTH_SCAN” android:usesPermissionFlags=”neverForLocation”/>

Before Android added the Nearby Devices runtime permission check, all BLE scans required the FINE_LOCATION permission. This is because the platform has no way of knowing why a BLE application is using BLE scans. It could be scanning for BLE beacons to get GPS coordinates, or it could be transferring health data from a BLE peripheral.

This led to a lot of user confusion. People were wondering why their BT thermometers were asking for precise location permission. This resulted in developers getting bad ratings on the app store.

To address this issue, Android introduced the Nearby Devices permission and the manifest check. This is to get developers on record that they will not be using BLE for location purposes.

However, if you include android:usesPermissionFlags=neverForLocation in your android manifest, some BLE beacons are filtered from the scan results.

Therefore, if you are using BLE for location purposes, you still need to get the FINE_LOCATION permission and the new Nearby Device runtime permission.

--

--