Android:通过Intent打开Google导航应用程序

5
我正在开发一款导航应用程序。在这些应用程序中,我需要打开地图应用程序,以启用交通功能,并在源纬度/地址和目的地之间绘制路径。
我已经创建了通过Intent打开Google地图并在两个点之间绘制路径的功能。
是否有可能在传递Intent时添加交通层?或者我需要添加哪个参数?
谢谢提前。
1个回答

4
你可以这样做:
我将我的“起始位置”作为“当前位置”考虑。
你的“目标位置”将是“动态的”,如下所示:
double destinationLatitude = 22.3000;
double destinationLongitude = 73.2003;

 String url = "http://maps.google.com/maps?f=d&daddr="+ destinationLatitude+","+destinationLongitude+"&dirflg=d&layer=t";
 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
 intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
 startActivity(intent);  

已完成


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接