2017-05-29 119 views
0

我能够与Android - 如何在驾驶模式中启用Google地图意图?

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

推出谷歌地图的意图如何可以启动在驾驶模式的意图(无目的地,除非事先在地图设置),这样它看起来像下面的截图?

enter image description here

我试着设置mode=driving但只开启普通地图中选择“驱动”选项卡:

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

回答

2

这将启动谷歌地图在驱动方式

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); 
1

我明白你想在导航模式打开谷歌地图应用。为了这个目的,你可以使用谷歌地图的URL 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); 

我希望这有助于!

+0

你是对的,它需要的目标使用travelmode =驾驶。我想知道是否有办法在没有目的地的情况下进入驾驶模式,如下所述:http://fieldguide.gizmodo.com/google-maps-driving-mode-is-your-essential-in-car-ai- 1776306949 –

相关问题