How do I get my app to start updating GPS location as soon as I open it?
Right now I have this code:
locationManager.requestLocationUpdates(bestProvider,0 ,0, loc_listener);
location = locationManager.getLastKnownLocation (bestProvider);
Which takes the best location. I ran my app on my phone and it got the location from where I was earlier today.
I want my app to update the gps location when I first open it.
I have been looking at these threads:
What is the simplest and most robust way to get the user's current location on Android?
Android find GPS location once, show loading dialog
But I am having trouble wiring everything up.
If I’m not mistaken you need to set up a listener and override the onLocationChanged method. That should get you your next GPS location ie the location after sat lock.
This tutorial should illustrate what i’m trying to say: http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2 .
Stop me if I’m wrong StackOverflow, I’m not sure of myself on this one.