打开内置地图意图以获取行车方向



我想打开一个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);

但它会打开一个对话框,询问使用浏览器或地图完成操作。我不想要那个对话框.

without open a 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));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
    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 + ""));

最新更新