MyLocationOverlay消失了,onResume上没有
我有一个地图视图,我向其中添加了 MyLocationOverlay。当应用程序从头开始(通过 onCreate)时,它显示良好。如果我退出应用程序(后退按钮)然后再次启动它(onResume),覆盖层就会消失。
我已经尝试解决这个问题 10 多个小时了。重新添加覆盖层会造成各种混乱。重置叠加层。更改地图位置,以便强制重新绘制。尝试手动使覆盖层失效或强制重绘。没有任何效果。
从代码的外观来看,Overlay 对象存在并且一切正常 - 但它只是不在地图上。
还有其他人遇到这个问题吗?
(不可思议的机器人,2.2)
I have a mapView to which I add a MyLocationOverlay. It displays fine when the app starts from 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
BACK 按钮会破坏 Activity。当你再次启动它时,
onCreate()
将再次被调用。因此,您需要弄清楚为什么有时您的onCreate()
无法添加叠加层。这是一个项目,它显示的叠加层不会受到您的影响问题——也许它可以作为比较点有用。
The BACK button destroys the activity. When you start it again,
onCreate()
will be called again. So, you need to figure out why sometimes youronCreate()
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.
在应用程序的其他地方,我
对此进行了评论,可以解决问题。奇怪的是,该行仅在 onCreate 期间调用一次,而在 onResume 期间根本不调用一次。
但是手动监听位置更新(使用实现 LocationListener 的类)似乎存在一些冲突。
如果我了解更多,我会回到这一点。
重要的! - 这可能是与这个问题相同的问题: 在 Android 上关闭并重新打开应用程序后 GPS 不会更新位置
Somewhere else in the app I have
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