0

I followed android guide to fetch current location(http://developer.android.com/training/location/retrieve-current.html).

I was previously testing my code on S3 wherein even if GPS is off getLastKnownLocation did return something. But now after testing on nexus I found out that getLastKnownLocation returns some location only if GPS is completely on.

In nexus there is three options for GPS : device only, off, complete. Maybe this has something to do with the problem.

In my application even low accuracy location would suffice. So guys what could be the problem ?

Harshit Syal
  • 649
  • 2
  • 11
  • 22
  • As far as I know it simply means that no previous location is known to the device. It should return a valid location if you for instance open google maps and let it find the position of the device before opening your own app. I think you just need to move to the next step of the guide and actively let the app look up the current location. – cYrixmorten Aug 25 '14 at 20:44
  • Right now I am thinking to show dialog whenever gps is off. Because I have verified that if GPS is on, I do get some location. But whats troubling me is why Network Location Provider is returning null. There should be atleast something in it. ! – Harshit Syal Aug 25 '14 at 20:54
  • Also I am thinking to experiment with platform Location API instead of play APIs, – Harshit Syal Aug 25 '14 at 20:55
  • If anyone happen to know of any good tutorial/github project where location is fetched in a proper manner please share. – Harshit Syal Aug 25 '14 at 20:56
  • Have a look at my answer here: http://stackoverflow.com/questions/19365035/location-servise-gps-force-closed/19366773#19366773 also linked to the original tutorial in the answer. I like this solution as the location code is boiled into a single class without the need to clutter the Activity. – cYrixmorten Aug 25 '14 at 21:27

0 Answers0