If I have ACCESS_FINE_LOCATION already, can I omit ACCESS_COARSE_LOCATION?
Asked Answered
S

4

100

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?

Splanchnology answered 9/3, 2013 at 12:37 Comment(0)
D
174

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.

Dissentious answered 9/3, 2013 at 12:43 Comment(4)
+1 but oddly, Google Maps doc recommend to use both: developers.google.com/maps/documentation/android/…Highgrade
Perhaps for phones that have network capabilities but no GPS?Kweichow
@NicklasA. logically, that shouldn't affect the fact that "fine" includes "coarse" - the missing provider will simply be missing. Also, if it were needed for that case, then I would expect Google docs to say so.Rhetorician
Update on @alex's comment: Google Maps now explicitly says you only need to request one permission. developers.google.com/maps/documentation/android-api/locationAbisha
O
22

Depends on your needs.

Permission wise, ACCESS_FINE_LOCATION includes ACCESS_COARSE_LOCATION. However, there is a catch:

ACCESS_COARSE_LOCATION gives you last-known location which is battery friendly https://developer.android.com/training/location/retrieve-current.html#setup
For example, if your app does something like location-based recommendations, last-known location is good enough.
This has a dependency on Google Play Services

However, if you need something like live/ real-time location like Pokemon Go, use ACCESS_FINE_LOCATION
It gives you live/ real-time location. You'll need to use a LocationListener
Last time I checked, this does not require Google Play Services

Oldcastle answered 1/12, 2016 at 2:49 Comment(2)
Would this permission be useful for Bluetooth LE scanning?Ghost
@Oldcastle maybe you can help me with location issues? #63918264 I have very strange behavior when listening for NMEA sentences.Beliabelial
T
7

Update

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.

Check this url: https://developer.android.com/training/location/permissions#approximate-request

Tincal answered 22/3, 2022 at 8:17 Comment(0)
B
1

Difference:

https://developer.android.com/training/location/permissions#accuracy https://developer.android.com/training/location/permissions#approximate-request

You need to ask for both permissions.

Approximate Provides an estimate of the device's location, to within about 1 mile (1.6 km). Your app uses this level of location accuracy when you declare the ACCESS_COARSE_LOCATION permission but not the ACCESS_FINE_LOCATION permission. Precise Provides an estimate of the device's location that is as accurate as possible, usually within about 160 feet (50 meters) and sometimes as accurate as within 10 feet (a few meters) or better. Your app uses this level of location accuracy when you declare the ACCESS_FINE_LOCATION permission.

If the user grants the approximate location permission, your app only has access to approximate location, regardless of which location permissions your app declares.

Your app should still work when the user grants only approximate location access. If a feature in your app absolutely requires access to precise location using the ACCESS_FINE_LOCATION permission, you can ask the user to allow your app to access precise location. ``

Then in Android 12 permission changes

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.

Biquarterly answered 27/12, 2021 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.