1

I can set my end point here. How can I set the start point with it?

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
xomena
  • 31,125
  • 6
  • 88
  • 117
Mahmoud Belal
  • 103
  • 1
  • 9

2 Answers2

0

Google launched new API: Google Maps URLs

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

This API allows to create

a universal, cross-platform URL to launch Google Maps and perform searches, get directions and navigation, and display map views and panoramic images.

From now on you can use something like

Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&dir_action=navigate");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

Hope this helps!

xomena
  • 31,125
  • 6
  • 88
  • 117
0

use below snippet:

String uri = "http://maps.google.com/maps?hl=en&saddr=" + currentlatLng.latitude + "," + currentlatLng.longitude + "&daddr=" + destination.latitude + "," + destination.longitude+ "&mode=driving";
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                startActivityForResult(intent, Constants.REQUEST_OPEN_GOOGLE_MAP);
Hardik Mehta
  • 867
  • 1
  • 12
  • 20
  • Google recommends using the Google Maps URLs: https://developers.google.com/maps/documentation/android-api/intents – xomena May 29 '17 at 10:53
  • @xomena in my scenario I have to use this for opening Google map app with lat lng. – Hardik Mehta May 29 '17 at 11:58
  • Perfect, the new and blessed by Google way is Google Maps URLs. Have a look at the docs, these URLs are cross-platform, so native apps can understand them easily. The same URL will work with Android, iOS or desktop browser. – xomena May 29 '17 at 12:35
  • @xomena ok i will check it, – Hardik Mehta May 29 '17 at 12:37