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?
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.
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
精彩评论