3 个 MapActivity 实例

发布于 2024-11-19 13:37:52 字数 776 浏览 1 评论 0原文

Maps API 中明确指出,每个进程只允许有一个 MapActivity。 我的问题是我需要 3 个,它不一定是 3 个活动,但它是 3 个实例。 我创建了一个旅行社应用程序,可让您预订酒店和活动。关注一下我的应用程序的酒店功能,当您搜索酒店时,您自然可以在地图上看到所有酒店,这是我需要的 MapActivity 的第一个实例,用于显示所有酒店。 如果您从 ListActivity 或 MapActivity 中选择酒店,您可以在 HotelInfoActivity 中看到该酒店的信息。 hotelInfoActivity 还引用了 MapActivity,它可以让您在地图上看到该特定酒店,而无需任何其他酒店......(下一步也将向其添加路线,但该功能尚未开发)。

当您执行以下场景时,会发生错误:

  1. 您输入所有酒店的地图
  2. ,您从 HotelInfoActivity 进入酒店信息
  3. ,您进入 MapActivity 以在地图上查看酒店(我启动相同的活动,但意图不同)我的 MapActivity 检测到的数据)。
  4. 到目前为止一切都很好。
  5. 我按返回键两次(返回到 HotelInfoActivity,然后返回到所有酒店的 MapActivity)。
  6. 我看到了之前的(单个酒店)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:

  1. you enter the map of all the hotels
  2. you get into the hotel info
  3. 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).
  4. till this point everything is ok.
  5. i press on back twice (back to HotelInfoActivity,then back to MapActivity of All Hotels).
  6. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清眉祭 2024-11-26 13:37:52

有什么办法可以解决这个问题吗?

正如文档所述,只有一个 MapActivity。对于您所描述的场景,您不需要多个 MapActivity。根据用户交互(例如,图标点击和“后退”按钮)更改叠加层和地图中心/缩放级别。

Is there is any way around that issue ?

Only have one MapActivity, as the documentation states. You do not need more than one MapActivity 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文