use*_*247 0 gps android geolocation android-location android-navigation
嗨我正在使用以下代码显示用户在当前位置和他的汽车位置之间的方向.
String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?saddr=%f,%f(%s)&daddr=%f,%f (%s)", curLat, curLong, "Your location", carLat, carLong, "Your vehicle location");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这很好但我需要在进入导航活动之前按下开始导航.我想要的是我需要直接进入导航活动,而无需按下开始导航按钮.
你可以在下面看到.左边的图像是我先得到的图像.点击底部的开始导航按钮后,我将轮流转向导航(右图).是否有可能直接转向默认Android应用程序的导航转向?

Ey,我刚遇到这个问题,你可以通过更改你在Intent上发送的URI来避免"按钮点击"操作.
尝试这样做:
LatLng destiny; // Your destiny LatLng object
String uri = "google.navigation:q=%f, %f";
Intent navIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String
.format(Locale.US, uri, destiny.latitude, destiny.longitude)));
if (canHandleIntent(this, navIntent))
startActivity(navIntent);
else
Toast.makeText(this, "Please install Google Navigation",
Toast.LENGTH_LONG).show();
Run Code Online (Sandbox Code Playgroud)
然后,如果您有多个应用程序来处理导航过程并且您想直接进行Google导航,则还可以包含对活动的"setClassName"调用的行:
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你 ;)
| 归档时间: |
|
| 查看次数: |
3688 次 |
| 最近记录: |