3

The app Im working on uses gps and sometimes in the onResume when the user restarts the app the location used is very old and sometimes very far away. It also will not update even when I have set the time to 0 in my location manager. Ive tried adding new listeners using both coarse and fine and switching from one to the other but I still cant get it to be reliable. Can some one point out to me what the best most reliable way to force a new location update in the onResume method. I no longer want to rely on lastLocationKnown as that is my problem now.

Edit: Maybe what I should have asked is how do I get a location that is constatly updated. It seems like you can only set your location as lastKnown which is giving me problems.

James andresakis
  • 5,335
  • 9
  • 53
  • 88

1 Answers1

1

I had a similar problem, and realised that onProviderEnabled() is not immediately called onResume(). I ended up not unregstering my listeners in onPause(), but instead unregistered them in onDestroy().

Here is the link to the relevant documentation: http://developer.android.com/reference/android/location/LocationListener.html

Here is the link to my original Stack Overflow question:
Why isn't Android's onProviderEnabled() method being called?

Hope this helps. Mel

Community
  • 1
  • 1
Mel
  • 6,214
  • 10
  • 54
  • 71
  • Hey thanks for the help :) I kept trying the same thing by setting my listeners to unregistered in the onPause method and was pulling out my hair because when I would start the app again I could see in my log cat that they would start up in onResume but would never return a new location. I started to think I was going to figure out how to get the onCreate method to fire just to reset everything. Ill move some stuff around and unregister everything in onDestroy and post back if I get it to work. – James andresakis Jan 30 '12 at 09:51
  • I had to do a little extra clean up that included making sure that if a location was older than so much time that I would just use a new coarse position and switch to the others as their accuracy picked up but I did implement my unregister method in ondestroy in my main class and now updates seem to come just like they should....thanks for the extra help :) – James andresakis Jan 31 '12 at 09:08