Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

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

Some questions about Android and Google Directions Service:

  • Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks? I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.

  • As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't know exactly if this is what you want, but you could fire up an intent like this:

String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));

To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".

This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.

Hope this helps somehow.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...