RCB*_*RCB 21 android android-intent android-navigation
我正在尝试从我的应用程序启动导航活动.我希望它从我的位置开始导航到我提供的点.我试过这种方式
String uri = "geo: "+String.valueOf(latitude) + "," + String.valueOf(longitude);
context.startActivity(new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(uri)));
Run Code Online (Sandbox Code Playgroud)
当我选择导航时它很好用Waze(它立即从"开始导航"对话框开始),但不起作用maps(仅显示点,而不是导航选项)
如果我使用这种方式
Intent intent =
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?" +
"&daddr=" + String.valueOf(latitude) + ","
+ String.valueOf(longitude)));
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
它的反面,开始导航,maps只显示点Waze
谢谢!
Ori*_*ion 25
我自己完成了这项工作,并且在使用它时没有遇到任何问题:
intent.setData(Uri.parse("geo:" + getLatitude() + "," +
getLongitude() + "?q=" + getStreet() + "+" +
getHousenumber() + "+" + getPostalcode() + "+" +
getCity()));
Run Code Online (Sandbox Code Playgroud)
不同之处在于我使用"&q ="查询Google所述的查询.
请参阅: https ://developer.android.com/guide/components/intents-common.html#Maps
这是一种简单的方法,适用于它们:
String uri = "geo: latitude,longtitude ?q= latitude,longtitude";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
Run Code Online (Sandbox Code Playgroud)
我希望这会很有用
| 归档时间: |
|
| 查看次数: |
11606 次 |
| 最近记录: |