質問

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.

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top