2014-03-06 79 views
4

我想从我的Android应用程序调用外部Google Maps应用程序。谷歌地图驾驶模式url方案不适用于Android

Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + stringLatitude + "," + stringLongitude + "&daddr=" + latitud + "," + longitud+"&dirflg=d")); 

startActivity(mIntent); 

它在Android 2.3.6上完美运作。

但不是在Android 4.2,我第一次点击执行该代码Google Maps的按钮被正确打开,但没有关于驾驶模式出现在那里。

但是,一旦我回到主应用程序,我再次点击按钮,一切正常。它只在第一次尝试时失败。

我不明白什么是对

任何线索去?

+0

我不能相信在下面的代码工作正常。实际上它发生的事情。 –

回答

1

我使用的Android 4.2

Intent i = new Intent(android.content.Intent.ACTION_VIEW, 
      Uri.parse("http://maps.google.com/maps?saddr="+a+","+b+"&daddr="+c+","+d+"&mode=driving")); 
i.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); 
startActivity(i); 
+0

它完美的作品!我也在'Android 4.3'上测试过它,它可以工作。非常感谢你! – Andoxko