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

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
arun
  • 245
  • 1
  • 3
  • 12

1 Answers1

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

Chirag Ghori
  • 4,231
  • 2
  • 20
  • 35