Launching Google Maps Directions via an intent on Android

Lars D picture Lars D · Apr 18, 2010 · Viewed 321.3k times · Source

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?

Answer

Jan S. picture Jan S. · Apr 18, 2010

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);

To start the navigation from the current location, remove the saddr parameter and value.

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.

This will fire up Google Maps in navigation mode directly:

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

UPDATE

In May 2017 Google launched the new API for universal, cross-platform Google Maps URLs:

https://developers.google.com/maps/documentation/urls/guide

You can use Intents with the new API as well.