3

How can i launch google maps transit get directions so that when i enter a source and destination by coordinates or by name of a place, google maps suggests transit (bus routes) directions. This is a code for bicycling but i couldn't find one for the transit in the developers.google.com (launch google maps).

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia&mode=b");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
Ali Akkawi
  • 313
  • 4
  • 13

2 Answers2

1

This is happening because your request has the mode value of 'b'

mode=b

Since there is not value for transit in the documentation to be passed for mode, this question has been raised by the SO community. Developers have came across various workarounds to deal with this situation.

Here are a few:

Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?

Android google.navigation Intent Modes?

Hope this Helps!!

Community
  • 1
  • 1
AniV
  • 3,997
  • 1
  • 12
  • 17
0

It's not documented, but 'r' is Public Transit.

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia&mode=r");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);