I have a GPS app that already requests ACCESS_FINE_LOCATION
permission in the manifest, now I want to add a library (MoPub) that requires ACCESS_COARSE_LOCATION
.
Am I correct in assuming that ACCESS_FINE_LOCATION
is enough, and I can leave out ACCESS_COARSE_LOCATION
from my manifest?
https://developer.android.com/develop/sensors-and-location/location/permissions#approximate-request
On Android 12 (API level 31) or higher, users can request that your app retrieve only approximate location information, even when your app requests the ACCESS_FINE_LOCATION runtime permission.
To handle this potential user behavior, don't request the ACCESS_FINE_LOCATION permission by itself. Instead, request both the ACCESS_FINE_LOCATION permission and the ACCESS_COARSE_LOCATION permission in a single runtime request. If you try to request only ACCESS_FINE_LOCATION, the system ignores the request on some releases of Android 12.
You need both. As an end user can grant only approximate access. So if you only have ACCESS_FINE_LOCATION
- you'll be left with no permissions approved. So both ACCESS_COARSE_LOCATION
and ACCESS_FINE_LOCATION
are required now.
https://developer.android.com/guide/topics/location/strategies.html#Permission
Note: If you are using both NETWORK_PROVIDER and GPS_PROVIDER, then you need to request only the ACCESS_FINE_LOCATION permission, because it includes permission for both providers. (Permission for ACCESS_COARSE_LOCATION includes permission only for NETWORK_PROVIDER.)
In short: yes, you don't need ACCESS_COARSE_LOCATION
if you've already defined ACCESS_FINE_LOCATION
.