-1

Is there a way in Andorid Studio to open the Google Maps App with already given parameters for routing (directions). Like there are many possible routes to get to your destination. I want to select or create my own routing to the destination and then starting Google Maps for Navigation.

Could you please help me?

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • Possible duplicate of [Launching Google Maps Directions via an intent on Android](https://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android) – Rumit Patel Jun 23 '18 at 14:05

1 Answers1

0

Answer is taken from Launching Google Maps Directions via an intent on Android.

Uri.Builder directionsBuilder = new Uri.Builder()
                .scheme("https")
                .authority("www.google.com")
                .appendPath("maps")
                .appendPath("dir")
                .appendPath("")
                .appendQueryParameter("api", "1")
                .appendQueryParameter("origin", "28.7041" + "," + "77.1025")
                .appendQueryParameter("destination", "18.5204" + "," + "73.8567");

        startActivity(new Intent(Intent.ACTION_VIEW, directionsBuilder.build()));

If you want origin as your current location, remove below line:

.appendQueryParameter("origin", "28.7041" + "," + "77.1025")
Rumit Patel
  • 8,830
  • 18
  • 51
  • 70