0

I have seen a huge amount of ways to get the users locations, my app displays local businesses so we don't need the most actuate location. Currently I am using:

 LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria = new Criteria();

        Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false)); 

To get the last locations when the app is opened, but some users are reporting that this does not work for them.

So what im really looking for is the best way to grab the users current location, quickly when the app is opened, no need to keep updating it.

DevWithZachary
  • 3,545
  • 11
  • 49
  • 101
  • 1)Don't use getLastKnownLocation. It will frequently return NULL. YOu need to request location updates and set a location listener, to ensure the location subsystem fetches a new one. 2)I'd avoid using Criteria. It really gives minimal advantage. Either you need accuracy (in which case use GPS) or you don't (in which case use network). Using a criteria just means you have to deal with all the problems of both systems. – Gabe Sechan Mar 18 '15 at 21:39
  • This will not work if users don't have a last location fix for the 'best' possible provider. As a next step, you should check all providers for which you have permissions. However, that will still fail if the phone has yet to get a fix of any kind when they start your app. Depending on how critical a location is, you may need to register an internet to listen for updates. – Noah Mar 18 '15 at 21:41

0 Answers0