8

I am working on a Android application that uses bluetooth and I want to use the new Android 12 Bluetooth_SCAN and CONNECT permissions to remove the need for location permission using

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

As shown in the bluetooth documentation

The problem is, the application has one main feature and one optional. The main feature works fine with these permissions.

However, the optional feature uses beacon scanning. These beacons are filtered out from scanning by the Android OS when using the "neverForLocation" flag.

Note: If you include neverForLocation in your android:usesPermissionFlags, some BLE beacons are filtered from the scan results.

The beacons appear during scanning if the flag is removed from the manifest permission.

However, if i remove this flag from the manifest, then even users that don't want to use this feature have to provide the location permission, or else the normal BLEScan returns nothing. This is something that i would like to avoid giving the fact that the whole reason for these new permission is to avoid asking the user for location.

Is there a way to provide this flag when making the actual runtime request to the OS for the permission instead of it being declared in the manifest? Any help or idea is appreciated.

Ionut
  • 678
  • 2
  • 19
  • I'm facing the same problem did you find a solution ? – Tamir Dec 01 '22 at 12:17
  • 1
    @Tamir Unfortunately no, I just ask the location permission all the time as well. – Ionut Dec 02 '22 at 13:23
  • 1
    I also didn't find how to do it, and it seems that for beacons we MUST ask for location permission, even it is not well documented. this is discussed also here: https://stackoverflow.com/questions/70578601/android-12-ble-scan-does-not-find-any-devices – Tamir Dec 03 '22 at 14:06
  • 1
    Yes, the documentation says that some beacons are filtered if we have that flag added. So far there is no way i could find to add or remove that flag during runtime. So without that, i just don't add it, and always ask location permission. – Ionut Dec 06 '22 at 20:44

0 Answers0