Does the GPS provider require the ACCESS_FINE_LOCATION permission or not?

1.1k views Asked by At

This SO thread seems to indicate that it does but the links to documentation in the same thread says:

Unless otherwise noted, all Location API methods require the Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION permissions. If your application only has the coarse permission then providers will still return location results, but the exact location will be obfuscated to a coarse level of accuracy.

Which makes me think that Google added coarse location support for the GPS provider. However, I am getting this error:

Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.

Of course the best way forward would be to use the fused location provider API but until then I think the documentation should be clearer about this? Mostly looking for an updated answer.

2

There are 2 answers

2
Narendra_Nath On

ACCESS_COARSE_LOCATION includes permission only for NETWORK_PROVIDER Not GPS.

Got to know more on this from the comments on this StackOverflow Thread

There seems to be a switch from the MarshmallowVersion. Pre Marshmallow the CoarseLocation let you use the Gps but obfuscate the location for privacy

0
Graziano On

The short answer is Yes.

To be complete, starting from API31 the use of the GPS provider requires both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions.
On lower APIs the GPS provider requires only the ACCESS_FINE_LOCATION permission.