Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress chooser dialog when calling Google map using intent

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

like image 742
Chirag Avatar asked Dec 02 '22 00:12

Chirag


2 Answers

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);
like image 85
Chirag Avatar answered Dec 17 '22 19:12

Chirag


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.

like image 22
jmcdale Avatar answered Dec 17 '22 19:12

jmcdale