2

我想打开一个inbuilt google map intent显示两个地方之间的路线而不打开一个complete action dialog, which asked for Browser and Map

我试过这个。

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+PreferenceData.getLatitude(HotelInfomation.this)+","+PreferenceData.getLongitude(HotelInfomation.this)+"&daddr="+latitude+","+longitude));
startActivity(intent);

但它会打开一个对话框,询问 Complete Action Using Browser 或 map 。我不想要那个 Dialog 。

4

2 回答 2

4
without open a complete action dialog, which asked for Browser and Map

在这种情况下,您需要告诉 android 您要使用哪个应用程序来显示地图。

干得好

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr="+PreferenceData.getLatitude(HotelInfomation.this)+","+PreferenceData.getLongitude(HotelInfomation.this)+"&daddr="+latitude+","+longitude));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
于 2012-06-20T11:26:44.177 回答
0
    Intent intent = new Intent(
                            android.content.Intent.ACTION_VIEW,
                            Uri.parse("http://maps.google.com/maps?saddr="
                                    + Data.map_latitude + ","
                                    + Data.map_longitude + "+&daddr="
                                    + Data.infoLatitude + ","
                                    + Data.infoLogitute + ""));
于 2012-06-20T11:32:01.287 回答