Android google.navigation Intent Modes?

后端 未结 2 1308
粉色の甜心
粉色の甜心 2020-12-16 23:50

I\'m currently developing an application that will launch a navigation intent. I know that this isn\'t an official API, but it works perfectly the way I want it to.

相关标签:
2条回答
  • 2020-12-17 00:36

    You should be able to append the travel mode as needed, with the travel modes listed below.

    • driving (default) indicates standard driving directions using the road network.
    • walking requests walking directions via pedestrian paths & sidewalks (where available).
    • bicycling requests bicycling directions via bicycle paths & preferred streets (where available).
    • transit requests directions via public transit routes (where available).

    If you would like to launch an Intent and allow the user to select between Maps or Browser you can do it this way.

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
    Uri.parse("http://maps.google.com/maps?saddr="+ starting_point_lat+","+starting_point_long+"&daddr="+dest_point_lat+","+dest_point_long+"&mode=transit"));
    startActivity(intent);
    
    0 讨论(0)
  • 2020-12-17 00:46

    After a bunch of guessing and hunting around, I have decided that it is impossible to launch directly to bus navigation, because that would involve CHOOSING a bus for the person to ride, which wouldn't make sense.

    Instead, you can launch them to a Google Maps search to the destination like so, thank you to this answer to a similar question:

    "http://maps.google.com/maps?daddr=lat,long&dirflg=r"

    With the &dirflag specifying public transit. (Why the "r" I have no idea...)

    0 讨论(0)
提交回复
热议问题