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

标签 android android-activity android-intent

我正在开发 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/

相关文章:

android - cordova 虚拟机初始化期间发生错误

java - 当屏幕旋转时,用户可以欺骗 Android

android - 使用 Intent 录制视频保存空文件

java - 如何创建像 Uber 这样的手机身份验证凭证?

java - 阻止来自 SDK Android 应用程序的网络调用

android - setImageURI/setimagebitmap 从网络中获取图像并在 ImageView 中显示

android - 与listview android的相对布局

android - 如何在 Activity 之间保持 FTP 连接(或任何连接对象) Activity

java - 测试 bundle 中是否存在某个值的更好方法?

android - 使用 Intent.ACTION_OPEN_DOCUMENT_TREE 时的起始路径