Google changed its map API for Android and introduced API V2. The previous codes for drawing path are not working with API V2.
I have managed to draw a path with API V2. I had searched a lot for the solution but did not find any answer. So I am sharing its answer.
First of all we will get source and destination points between which we have to draw route. Then we will pass these attribute to below function.
This function will make the url that we will send to get Direction API response. Then we will parse that response . The parser class is
This parser will return us string. We will call it like that.
Now we will send this string to our drawpath function. The drawpath function is
Above code will draw the path on mMap. The code of decodePoly is
As direction call may take time so we will do all this in Asynchronous task.
My Asynchronous task was
I hope it will help.