4

I want to call google map intent without showing "Complete Action Dialog"?

Is it possible? Here is my code.

String uri = "http://maps.google.com/maps?saddr=" + Utils.getLatitude(ShowDetails.this)+","+Utils.getLongitude(ShowDetails.this)+"&daddr="+userLatitude+","+userLongitude;
startActivity(new Intent(android.content.Intent.ACTION_DEFAULT, Uri.parse(uri)));

I dont want to show below dialog when calling google map intent . Any Help is appreciated .

enter image description here

1

3 Answers 3

12

Below code helps me to solve my question.

String uri = "http://maps.google.com/maps?saddr=" + Utils.getLatitude(ShowDetails.this)+","+Utils.getLongitude(ShowDetails.this)+"&daddr="+userLatitude+","+userLongitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
1
  • Thank you , it helped me too much , but what if want to add more than a place to the map ,? do you have an idea? Commented Sep 23, 2012 at 16:50
6

Use the Google Maps URI rather than "http://[...] "

It goes something like this:

String uri = "geo:" + latitude + "," + longitude

Check out http://developer.android.com/guide/appendix/g-app-intents.html for the info.

4
  • what is the uri for showing driving direction on google map ?
    – Chirag
    Commented Nov 15, 2011 at 6:05
  • You can try placing the necessary info after the '?' of geo:0,0?q=my+street+address and see if that works.
    – jmcdale
    Commented Nov 15, 2011 at 6:09
  • can you give me example using above my string uri in question .
    – Chirag
    Commented Nov 15, 2011 at 6:12
  • I'm not sure if I can; I really have no idea if the geo uri will work the way you'd like it to. I would just try a few different things to see if they'd work. Maybe try adding everything after the ? in the http uri. Also, read more here: stackoverflow.com/questions/2662531/…
    – jmcdale
    Commented Nov 15, 2011 at 6:18
0

Try ACTION_VIEW instead of ACTION_DEFAULT:

String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

check this Android doc Intents List and browse to "Google Maps".

1
  • @ChiragRaval dear its not working fine here. I have tested in my phone as to check your comment. Commented Nov 15, 2011 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.