gpt4 book ai didi

android 应用程序调用带有汽车、公共(public)、步行控件的谷歌地图

转载 作者:行者123 更新时间:2023-11-29 00:41:04 27 4
gpt4 key购买 nike

我在将 Iphone 应用程序的某些功能移植到 Android 时遇到问题。基本上从这个应用程序调用的 iphone 谷歌地图应用程序看起来像这样

enter image description here

我曾尝试使用此伪代码复制类似的行为

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr="+LAT_POSITION+","+LONG_POSITION+"&daddr="+Lat+","+Lon + "&dirflg=w"));
startActivity(intent);

它做了什么,它以这种形式带来了 android map 应用程序

enter image description here

然后当我点击显示 map 时我得到

enter image description here

然后当我按回两次时我得到了这个

enter image description here

我的问题是。

如何让(汽车、公共(public)、步行)控件覆盖 map ?就像在 iphone 应用程序中一样 - 在一个屏幕上(如果可能的话,还有其他元素)

补充问题..如何启用默认显示 map ? (而不是文本方向,这是在 android 2.2 中发生的——我已经用 froyo 检查了 samsung galaxy),在 4.0(模拟器)中 map 默认显示,但仍然没有覆盖控件(汽车、公共(public)、步行)。

最佳答案

您可以使用 setComponent 明确告诉 map 应用使用 com.google.android.maps.MapsActivity 来解析 Intent :

Intent intent = new Intent(Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=" + LAT_POSITION + "," + LONG_POSITION +
"&daddr=" + lat + "," + lon + "&dirflg=w"));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);

您应该会看到方向叠加层,但我不确定在用户点击“开始”之前它会绘制路线。

当然,这是“非 API”,并假设 map 已安装在设备上,并且 Google 不会更改 MapsActivity 的内部包或类名。

关于android 应用程序调用带有汽车、公共(public)、步行控件的谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9315233/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com