1

Am using the following code to open google map from my app with driving mode.

 String url = "http://maps.google.com/maps?f=d&daddr="+latitude+","+longitude+"&mode=driving";
 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
 intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
 startActivity(intent);

But Google map always showing walking option as shown in image. Any way to change this ?

enter image description here

1 Answer 1

5

You can use &dirflg=d for driving directions.

So, now your code should look like this

String url = "http://maps.google.com/maps?f=d&daddr="+latitude+","+longitude+"&dirflg=d";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);   

Google map direction modes :

dirflg=r - Switches on "Public Transit" (Railway direction)- only works in some areas.

dirflg=w - Switches to walking directions - still in beta.

dirflg=d - Switches to driving directions

0

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