1

I have one screen in app which shows address. Now I want to open google when while click on that address. And it have to show directions from current location to that address.

//code in app

 Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse("http://maps.google.com/maps?daddr=28.5600697,77.2695753"));
            startActivity(intent);

but it is not opening location only processing.

Dheeraj Singh
  • 21
  • 1
  • 5

4 Answers4

0

Try this

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse("http://maps.google.com/maps?q=28.5600697,77.2695753"));
            startActivity(intent);

and please let me know if it works.

theapache64
  • 10,926
  • 9
  • 65
  • 108
0

Try something like this. this will Suppress chooser dialog when calling Google map using intent

                    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse("http://maps.google.com/maps?saddr="+Latitude+","+Longitude+"&daddr="+latitude+","+longitude));
                    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                    startActivity(intent);
Ali Ahsan
  • 460
  • 3
  • 13
0

Try this code

 float storeLatitude = Float.parseFloat(storeList.latitude + "");
 float storeLongitude = Float.parseFloat(storeList.longitude + "");

 String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", storeLatitude, storeLongitude, "Store Address");
 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
 intent.setPackage("com.google.android.apps.maps");
 startActivity(intent);
Akash
  • 961
  • 6
  • 15
0

First you need to fetch user's current Latitude and Longitude than use following :

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
    Uri.parse("http://maps.google.com/maps?saddr=" + mUserLatitude + ", " + mUserLongitude +
   "&daddr=" + lat + ", " + lon));
    startActivity(intent);

Where lat , lon is destination Latitude and Longitude resepectively.

Krishna Meena
  • 5,693
  • 5
  • 32
  • 44