0

I have a service running in which I implement "Location Listener", basically i create my LocationManager like this:

lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000*2,0, this);

and i try to make a string on my onLocationChanged(Location location) like this:

route = String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude());

The problem is that unless i wait a lot of time my Listener won't get the location updates, because gps_provider takes its time to get ready.

I have all the permissions in the manifest for this feature, and i ask for gps to be enabled before starting this service.

Is there any option for making my app wait until the gps is ready?

I want my app to wait until the GPS is ready to give locations, just to tell the user that he/she must wait until that moment to start.

  • Please clarify your question, you want your app to wait until GPS is ready? how will the app wait? what should not occur? and do you really want a margin of 30 seconds between location tracks? – Mohammad Haidar May 25 '16 at 08:11
  • Yes, i want my app to wait until GPS is ready. I dont mind how it waits (ProgressDialog or similar), i just want to tell the user of the app that he/she must wait some time. And finally the 30 seconds were for the example, i dont want 30 seconds in the final version. – ivan del burgo May 25 '16 at 08:15
  • Did you see this - http://stackoverflow.com/questions/15453576/android-check-if-gps-is-searching-has-fix-or-is-not-in-use – TDG May 25 '16 at 08:44
  • And how is it hard to display a loading dialog which blocks the user interactions and dismiss it when onLocationChanged(Location location) is invoked? – Mohammad Haidar May 25 '16 at 09:24
  • GPS Does't work well some time on basement any or ground area also. may be problem, i just suppose – Aditay Kaushal May 25 '16 at 09:58

0 Answers0