简体   繁体   中英

Directions via Intent Automatically

I building an app that contains many addresses. A user can select an address in a listview. This should automatically show a user directions to that address from the users current location.

 String uri = "geo:"+ selectedAddress.getLat+","+getLng();
 StartActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(uri)));

I know all this does is show the location of the specified co-ords.

How would i go about showing the directions to the location from the users current location?

ask the user for the place and do the following way:

String place="";//user gives the place.
String url = "http://maps.google.com/maps?daddr="+place;
Intent drn = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
startActivity(drn);

Google will automatically take the current user location as starting point and give directions

How would i go about showing the directions to the location from the users current location?

As @Frxstrem indicated, there is no documented and supported Intent to bring up directions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM