Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get *coarse* location from GPS provider on Android

My app only needs very rough location data, so I originally set my manifest permissions to ACCESS_COARSE_LOCATION, and set up a location listener for NETWORK_PROVIDER. This gave me exactly the kind of rough location estimate I needed, but only with Google Location Services turned on.

I was expecting that if the user only had GPS enabled, that I would still receive a rough estimate of their location. But it seems like the only way to get ANY location information from the GPS_PROVIDER is by using the ACCESS_FINE_LOCATION permission.

So, is it true that with only GPS enabled, an app cannot receive location information unless it has the ACCESS_FINE_LOCATION permission? In other words, the GPS_PROVIDER can't send rough location estimates if the app only has ACCESS_COARSE_LOCATION permission?

like image 652
Josh Avatar asked Jan 22 '13 14:01

Josh


People also ask

What is coarse location android?

android. permission. ACCESS_COARSE_LOCATION – Allows the API to return the device's approximate location. The permission provides a device location estimate from location services, as described in the documentation about approximate location accuracy.

What is android location provider?

LocationProvider is the super class for location providers. A location provider provides the information of the geographical location of the device. This information is stored in the Location class. For accessing the location based services Android provide different classes that are available in android.

How accurate is coarse location android?

Android distinguishes two location provider types with the following accuracy: Fine-grained location provider like the GPS provider with an accuracy of less than 100 m. Coarse-grained location provider like the network location provider with an accuracy of 100 – 500 m.


1 Answers

So, is it true that with only GPS enabled, an app cannot receive location information unless it has the ACCESS_FINE_LOCATION permission?

Generally speaking, yes.

Quoting the documentation for LocationManager:

If your application only has the coarse permission then it will not have access to the GPS or passive location providers. Other providers will still return location results, but the update rate will be throttled and the exact location will be obfuscated to a coarse level of accuracy.

 

In other words, the GPS_PROVIDER can't send rough location estimates if the app only has ACCESS_COARSE_LOCATION permission?

Quoting the Android 4.2 release notes:

Compared to previous versions of Android, user location results may be less accurate if your app requests the ACCESS_COARSE_LOCATION permission but does not request the ACCESS_FINE_LOCATION permission. To meet the privacy expectations of users when your app requests permission for coarse location (and not fine location), the system will not provide a user location estimate that’s more accurate than a city block.

However, I am assuming that this does not supersede the "will not have access to the GPS" statement from LocationManager. I assume that this means that NETWORK_PROVIDER data might be inhibited, if it is deemed too accurate.

like image 140
CommonsWare Avatar answered Sep 28 '22 00:09

CommonsWare