Reputation: 245
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 ?
Upvotes: 1
Views: 3674
Reputation: 4231
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
Upvotes: 5