androidpermissionsbluetoothandroid-11

Bluetooth FINE_LOCATION and COARSE_LOCATION Permissions on Android 11 or lower


I want to connect and communicate with an Android device via a Bluetooth SPP socket. Therefore, I need to specify the correct Bluetooth permissions in the Manifest and request them at runtime in the app.

According to the official Bluetooth permission documentation, on Android 11 or lower, I need to request the following permissions:

However it is stated:

If your app targets Android 9 (API level 28) or lower, you can declare the ACCESS_COARSE_LOCATION permission instead of the ACCESS_FINE_LOCATION permission.

Therefore, I would expect that I don't need to declare ACCESS_COARSE_LOCATION, even for Android 9 or lower.

Nevertheless, the IDE states:

If you need access to FINE location, you must request both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION

Why do i need to request booth ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions, shouldn't it be sufficient to only request ACCESS_FINE_LOCATION?

The permission requirements are fulfilled when I request both but i want to keep my code clean and minimal in addition to understanding the permission guidelines.


Solution

  • You are correct that for Bluetooth connectivity, the ACCESS_COARSE_LOCATION permission is not necessary. The IDE suggestion to request both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions may not be applicable in the context of Bluetooth communication. It seems to be more likely a generic recommendation based on typical location-based app development scenarios than a really need...

    In the case of Bluetooth, the requirement is typically limited to ACCESS_FINE_LOCATION permission. The ACCESS_COARSE_LOCATION permission is not specifically required for Bluetooth functionality. There is even no statement in provided documentation that you can declare ACCESS_COARSE_LOCATION permission instead of the ACCESS_FINE_LOCATION permission at Android 9 (API level 28) or lower. On the contrary there is written following statement:

    ACCESS_FINE_LOCATION is necessary because, on Android 11 and lower, a Bluetooth scan could potentially be used to gather information about the location of the user.

    To summarize:

    For Bluetooth connectivity, you should declare and request the BLUETOOTH and BLUETOOTH_ADMIN permissions in your app's manifest.

    Additionally, you should declare and request the ACCESS_FINE_LOCATION permission, as Bluetooth scans are considered a form of location access starting from Android 6.0 (API level 23).

    The IDE suggestion to request both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions might be a generic recommendation based on typical location-based app development scenarios. However, in the case of Bluetooth communication, it is sufficient to request only the ACCESS_FINE_LOCATION permission.