Android Google Maps Driving Direction
<p>I'm developing an android Google maps in my thesis, can i ask something about Driving Directions in Android?.</p>

<p>Here is my question.</p>

<p>"How can i generate a random driving directions in android Google maps when a button is clicked, it will randomly give the path from starting point to destination point."</p>

<p>Thank you!.</p>

<p>I asked google maps through this.</p>

<pre><code>    private void parsing(GeoPoint start, GeoPoint end) throws ClientProtocolException, IOException, JSONException, URISyntaxException{
    HttpClient httpclient = new DefaultHttpClient();
    StringBuilder urlstring = new StringBuilder();
    urlstring.append("https://maps.googleapis.com/maps/api/directions/json?origin=")
    .append(Double.toString((double)start.getLatitudeE6()/1E6)).append(",").append(Double.toString((double)start.getLongitudeE6()/1E6)).append("&amp;destination=")
    .append(Double.toString((double)end.getLatitudeE6()/1E6)).append(",").append(Double.toString((double)end.getLongitudeE6()/1E6))
    .append("&amp;sensor=false");
    //urlstring.append("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;destination=Montreal&amp;sensor=true");
    url = new URI(urlstring.toString());

    HttpPost httppost = new HttpPost(url);

    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
    InputStream is = null;
    is = entity.getContent();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
    StringBuilder sb = new StringBuilder();
    sb.append(reader.readLine() + "\n");
    String line = "0";
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
    }
    is.close();
    reader.close();
    String result = sb.toString();
    JSONObject jsonObject = new JSONObject(result);
    JSONArray routeArray = jsonObject.getJSONArray("routes");
    JSONObject routes = routeArray.getJSONObject(0);
    JSONObject overviewPolylines = routes.getJSONObject("overview_polyline");
    String encodedString = overviewPolylines.getString("points");
    List&lt;GeoPoint&gt; pointToDraw = decodePoly(encodedString);

    //Added line:
    mv_mapview.getOverlays().add(new RoutePathOverlay(pointToDraw));
}
</code></pre>

<p>Tapped on the map.</p>

<pre><code>    class MapOverlay extends Overlay {

        @Override
        public boolean onTap(final GeoPoint p, MapView mapView) {
            // TODO Auto-generated method stub

            geop_Tpoint = p;
            mcon_mapcontrol = mapView.getController();
            mcon_mapcontrol.animateTo(p);

            mv_mapview.invalidate();

            longitude = (int)(p.getLongitudeE6()*1E6);
            latitude = (int)(p.getLatitudeE6()*1E6);



            new AlertDialog.Builder(ShowMap.this)
                    .setTitle("Routes")
                    .setMessage("Display Routes?")
                    .setNegativeButton("NO",
                            new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog,
                                        int which) {
                                    // TODO Auto-generated method stub

                                    textlocation.setText("Tap in the Map for Destination!");
                                    dialog.dismiss();


                                }
                            })
                    .setPositiveButton("YES",
                            new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog,
                                        int which) {
                                    // TODO Auto-generated method stub
                                    try{
                                        textlocation.setText("");
                                        parsing(geop_startpoint,geop_Tpoint);
                                        geocodeExecuter(geop_startpoint,geop_Tpoint);
                                        showButton.setEnabled(true);


                                    }catch(Exception e){

                                        textlocation.setText(""+ e.getMessage());

                                    }


                                }

                            }).show();
            showButton.setEnabled(true);
            return true;
        }
</code></pre>

<p>The starting point is through GPS it will give me where im I.</p>
