繁体   English   中英

Android-如何在行驶模式下启动Google Map Intent?

[英]Android - How to launch Google map intent in driving mode?

我可以通过以下方式启动Google Maps Intent

Uri location = Uri.parse("geo:0,0");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
startActivity(mapIntent);

如何在“ 驾驶”模式下启动意图(无目的地,除非先前在“地图”中设置了),以使它看起来像下面的屏幕截图?

在此处输入图片说明

我尝试设置mode=driving但是只打开了带有“ driving”标签的常规地图:

 Uri location = Uri.parse("geo:0,0?mode=driving");

这将在驾驶模式下启动Google地图

    Intent intent = getPackageManager().getLaunchIntentForPackage("com.google.android.apps.maps");
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("google.navigation:/?free=1&mode=d&entry=fnls"));
    startActivity(intent);

我们了解到您想以导航模式打开Goog​​le Maps应用。 为此,您可以使用Google Maps URLs API中描述的URL:

https://developers.google.com/maps/documentation/urls/guide#directions-action

以下代码应该可以解决问题,我相信您需要提供一个目标参数才能直接打开此模式

String URL = "https://www.google.com/maps/dir/?api=1&travelmode=driving&dir_action=navigate&destination=Los+Angeles";
Uri location = Uri.parse(URL);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
startActivity(mapIntent);

我希望这有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM