gpt4 book ai didi

android - 默认情况下如何在 map View 中启动 Activity ?

转载 作者:太空狗 更新时间:2023-10-29 13:38:39 36 4
gpt4 key购买 nike

我正在开发 android 应用程序来获取两个位置之间的方向,如下所示

Intent intent = new Intent(android.content.Intent.ACTION_VIEW;
Uri.parse("http://maps.google.com/maps?saddr=12.84281852,80.22529753&daddr=13.00355419,80.200881958"));
startActivity(intent);

运行这个应用程序,它提示我在 1) 浏览器 2) map 中选择一个如何在编码中默认在map中打开??

最佳答案

我想如果你调用setPackage()使用 'com.google.android.apps.maps' 它应该启动 Google map 。


这对我来说效果很好:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);

关于android - 默认情况下如何在 map View 中启动 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8267281/

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