3 个 MapActivity 实例
Maps API 中明确指出,每个进程只允许有一个 MapActivity。 我的问题是我需要 3 个,它不一定是 3 个活动,但它是 3 个实例。 我创建了一个旅行社应用程序,可让您预订酒店和活动。关注一下我的应用程序的酒店功能,当您搜索酒店时,您自然可以在地图上看到所有酒店,这是我需要的 MapActivity 的第一个实例,用于显示所有酒店。 如果您从 ListActivity 或 MapActivity 中选择酒店,您可以在 HotelInfoActivity 中看到该酒店的信息。 hotelInfoActivity 还引用了 MapActivity,它可以让您在地图上看到该特定酒店,而无需任何其他酒店......(下一步也将向其添加路线,但该功能尚未开发)。
当您执行以下场景时,会发生错误:
- 您输入所有酒店的地图
- ,您从 HotelInfoActivity 进入酒店信息
- ,您进入 MapActivity 以在地图上查看酒店(我启动相同的活动,但意图不同)我的 MapActivity 检测到的数据)。
- 到目前为止一切都很好。
- 我按返回键两次(返回到 HotelInfoActivity,然后返回到所有酒店的 MapActivity)。
- 我看到了之前的(单个酒店)MapActivity。
有什么办法可以解决这个问题吗?很高兴我在活动堆栈上有两个活动实例,这样我就可以导航回每个实例,但如何防止它们将状态从一个实例传递到另一个实例???
(顺便说一句,第三个例子是在您预订酒店之后,您可以在地图上看到它,但由于某种原因我没有遇到问题)。
It states clearly in the Maps API that only one MapActivity per process is allowed.
My problem is i need 3, it's not necessarily 3 Activities but it is 3 instances.
I created a Travell agent app that allows you to book hotels and activities. focusing for a second in the hotels feature of my app, when you search hotels you can, naturally, see the all on the map, this is the first instance of the MapActivity i need, to show all hotels.
If you choose hotel either form the ListActivity or from the MapActivity you can see that hotel's info in HotelInfoActivity. the hotelInfoActivity also has reference to a MapActivity that lets you see that specific hotel on the map without any other hotels.... (next step would be to add routes to that as well, but that feature is not in development just yet).
The bugs happen when you do the following scenario:
- you enter the map of all the hotels
- you get into the hotel info
- from the HotelInfoActivity you get into the MapActivity to see the hotel on the map ( I start the same activity but with intent with different data which is detected by my MapActivity).
- till this point everything is ok.
- i press on back twice (back to HotelInfoActivity,then back to MapActivity of All Hotels).
- i see the previous (single hotel) MapActivity.
Is there is any way around that issue ? it's great that i have two instances of the activity on the activities stack so i can navigate back to every instance, but how can i prevent them to pass states from one instance to another ????
(BTW the third instance is AFTER you've reserved the hotel you have the ability to see it on the map, but i don't have problems there for some reason).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如文档所述,只有一个
MapActivity
。对于您所描述的场景,您不需要多个MapActivity
。根据用户交互(例如,图标点击和“后退”按钮)更改叠加层和地图中心/缩放级别。Only have one
MapActivity
, as the documentation states. You do not need more than oneMapActivity
for the scenario you have described. Change your overlays and map center/zoom levels based upon user interaction (e.g., icon taps and BACK button).