views:

977

answers:

2

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?

+1  A: 

I looked into this a while back -- there's no documented Intent for this at this time. Sorry!

CommonsWare
+5  A: 

You could use something like this:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345");
startActivity(intent);

You can use an actual street address instead of latitude and longitude. However this will give the user a dialog to choose between opening it via browser or Google Maps.

If you are in the US, you could use an unofficial way (Since it isn't official, I don't recommend using it). This will fire up Google Maps in navigation mode. Haven't played with it since where I live it isn't available.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=an+address+city");
janfsd