Launching Google Maps Directions via an intent on

2018-12-31 06:54发布

My app needs to show Google Maps directions from A to B, but I don't want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this possible? If yes, how?

14条回答
春风洒进眼中
2楼-- · 2018-12-31 07:49

Well you can try to open the built-in application Android Maps by using the Intent.setClassName method.

Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("geo:37.827500,-122.481670"));
i.setClassName("com.google.android.apps.maps",
    "com.google.android.maps.MapsActivity");
startActivity(i);
查看更多
梦该遗忘
3楼-- · 2018-12-31 07:51

try this

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr="+src_lat+","+src_ltg+"&daddr="+des_lat+","+des_ltg));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
查看更多
登录 后发表回答