I am developing application to track user location. In that I need to know how to show shortest direction from one location to another in Map Activity.I should not be a straight line. It should be like a road path.
If you want to draw a polyline between 2 points and following road, you can try with the library Google-Directions-Android
You can add the library on gradle with compile 'com.github.jd-alexander:library:1.0.7'
You can use all your point (Latlng) and use them into the waypoint method.
Routing routing = new Routing.Builder()
.travelMode(/* Travel Mode */)
.withListener(/* Listener that delivers routing results.*/)
.waypoints(/*waypoints*/)
.build();
routing.execute();
actual code
start = new LatLng(18.015365, -77.499382);
waypoint= new LatLng(18.01455, -77.499333);
end = new LatLng(18.012590, -77.500659);
Routing routing = new Routing.Builder()
.travelMode(Routing.TravelMode.WALKING)
.withListener(this)
.waypoints(start, waypoint, end)
.build();
routing.execute();