I have a mapView to which I add a MyLocationOverlay. It displays fine when the app starts fro开发者_如何学编程m scratch (goes through onCreate). If I exit the app (back button) and then start it again (onResume), the overlay is gone.
I have tried to fix this for 10+ hours. All sorts of messing with re-adding the overlay. Resetting the overlays. Changing the maps location so it's forced to redraw. Trying to manually invalidate or force a redraw of the overlay. NOTHING has worked.
From the way the code looks, the Overlay object exists and everything is working fine - but it's just not on the map.
Is anybody else having this problem?
(Droid Incredible, 2.2)
If I exit the app (back button) and then start it again (onResume), the overlay is gone.
The BACK button destroys the activity. When you start it again, onCreate()
will be called again. So, you need to figure out why sometimes your onCreate()
is failing to add an overlay.
Here is a project that displays overlays that does not suffer from your problem -- perhaps it can be useful as a point of comparison.
Somewhere else in the app I have
_locationManager.requestLocationUpdates(provider, Vars.GPS_MIN_UPDATE_MILLISECS, Vars.GPS_MIN_UPDATE_METERS, _locationListener);
Commenting this out fixes the problem. Weirdly this line is only called once during onCreate and NOT at all during onResume.
But there seems to be some conflict in listening to the location updates manually (with a class implementing LocationListener).
I will return to this if I figure out more.
Important! - it's probably the same issue as this question: GPS not update location after close and reopen app on android
精彩评论