Android: how and why not to use ACCESS_COARSE_LOCATION

I will start from why you should avoid using ACCESS_COARSE_LOCATION directive in your Manifest.xml file.
ACCESS_COARSE_LOCATION allows you to get approximate location of user’s device. It is detected not by GPS, but using different means – wifi hotspots, network triangulation etc.
Actually, it is pretty accurate and it is worth considering to use in case you need detect user’s location up to 500 meters.
2014-07-09 09.42.28The problem is, that you still need to enable High Accuracy setting for Location detection in your device to make this feature work properly. I got reports from users, that on some devices it should be done in order to make this feature work.
Another big problem with this directive is that Google Play excludes a big number of devices in case it is included into Manifest.xml.
I tested app upload with ACCESS_COARSE_LOCATION and without and found, that without it there is more than 6400 devices supported and with – about 300 less. I checked and found many popular devices in exclusion list.

So, in case you don’t need 500 meters radius location, but only Country and City, then avoid using ACCESS_COARSE_LOCATION.

And now I will tell you how to detect location without using build-in methods.

First, I created a simple php script, which is located on my server.

It does a really simple work – returns json output from
It looks as following:

And now some Java code for our Android app:

And here is the screenshot, how it looks like:2014-07-09 09.58.40