Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: open Map intent with directions with two points

How to open map intent with directions?

I know about

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "geo:%.8f,%.8f", latitude, longitude)));
startActivity(Intent.createChooser(intent, "Select an application"));

This code works fine for ONE point. But I want to show dialog with ALL map-applications, and open directions from point A to point B with any application (Google Map, Citymapper, web browser, etc).

like image 361
monyag Avatar asked Aug 07 '14 19:08

monyag


People also ask

How do you link directions on Google Maps?

On your computer, open Google Maps. Go to the directions, map, or Street View image you want to share. Select Share or embed map. If you don't see this option, click Link to this map.


1 Answers

have you tried this

String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+latitude1+","+longitude1+"&daddr="+latitude2+","+longitude2;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(Intent.createChooser(intent, "Select an application"));
like image 98
ColdFire Avatar answered Oct 05 '22 01:10

ColdFire