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

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
Chirag
  • 56,621
  • 29
  • 151
  • 198

3 Answers3

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);
Chirag
  • 56,621
  • 29
  • 151
  • 198
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.

Chirag
  • 56,621
  • 29
  • 151
  • 198
jmcdale
  • 4,463
  • 2
  • 16
  • 20
  • what is the uri for showing driving direction on google map ? – Chirag Nov 15 '11 at 06:05
  • You can try placing the necessary info after the '?' of `geo:0,0?q=my+street+address` and see if that works. – jmcdale Nov 15 '11 at 06:09
  • can you give me example using above my string uri in question . – Chirag Nov 15 '11 at 06: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: http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android – jmcdale Nov 15 '11 at 06: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".

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295