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?

Vasily Kabunov
  • 6,511
  • 13
  • 49
  • 53
charliefortune
  • 3,072
  • 5
  • 28
  • 48

4 Answers4

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.

Connor Tumbleson
  • 3,270
  • 2
  • 25
  • 37
  • 14
    +1 but oddly, Google Maps doc recommend to use both: https://developers.google.com/maps/documentation/android/start?hl=fr#specify_app_settings_in_the_application_manifest – alex Feb 14 '14 at 00:21
  • 3
    Perhaps for phones that have network capabilities but no GPS? – Nicklas A. Oct 31 '14 at 17:46
  • 4
    @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. – ToolmakerSteve Sep 25 '15 at 11:07
  • 15
    Update on @alex's comment: Google Maps now explicitly says you only need to request one permission. https://developers.google.com/maps/documentation/android-api/location – Klox Feb 04 '17 at 18:05
20

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

ericn
  • 12,476
  • 16
  • 84
  • 127
  • Would this permission be useful for Bluetooth LE scanning? – IgorGanapolsky Aug 03 '17 at 19:07
  • @ericn maybe you can help me with location issues? https://stackoverflow.com/questions/63917764/gpgga-and-gprmc-sentences-are-not-received-in-onnmeamessage I have very strange behavior when listening for NMEA sentences. – Viktor Apoyan Sep 22 '20 at 08:17
6

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

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
هيثم
  • 791
  • 8
  • 11
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.

Nafis Kabbo
  • 568
  • 5
  • 8