Android: Draw line between two geopoints using edit text value
<p>"I want to pass editText value to getDirectionData() but it will generate force close error."</p>

<pre><code>public class DisplayRoute extends MapActivity{
                MapView myMapView = null;
                MapController myMC = null;
                GeoPoint geoPoint = null;
                EditText edt1;
                EditText edt2;

                 public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.currentlocation);
                    edt1 = (EditText)findViewById(R.id.edit_route);
                    edt2 = (EditText)findViewById(R.id.edit_destination);

                    myMapView = (MapView) findViewById(R.id.themap);
                    geoPoint = null;
                    myMapView.setSatellite(true);
</code></pre>

<p>//My major area of problem is there and please send me the appropriate method to further progress in my application..
                   String pairs[] = getDirectionData(edt1.getText().toString(),edt2.getText().toString());
                          String[] lngLat = pairs[0].split(",");</p>

<pre><code>                      // STARTING POINT
                      GeoPoint startGP = new GeoPoint(
                        (int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double
                          .parseDouble(lngLat[0]) * 1E6));

                      myMC = myMapView.getController();
                      geoPoint = startGP;
                      myMC.setCenter(geoPoint);
                      myMapView.getOverlays().add(new DirectionPathOverlay(startGP, startGP));

                      // NAVIGATE THE PATH

                      GeoPoint gp1;
                      GeoPoint gp2 = startGP;

                      for (int i = 1; i &lt; pairs.length; i++) {
                       lngLat = pairs[i].split(",");
                       gp1 = gp2;
                       // watch out! For GeoPoint, first:latitude, second:longitude

                       gp2 = new GeoPoint((int) (Double.parseDouble(lngLat[1]) * 1E6),
                         (int) (Double.parseDouble(lngLat[0]) * 1E6));
                       myMapView.getOverlays().add(new DirectionPathOverlay(gp1, gp2));
                       Log.d("xxx", "pair:" + pairs[i]);
                      }

                      // END POINT
                      myMapView.getOverlays().add(new DirectionPathOverlay(gp2, gp2));

                      myMapView.getController().animateTo(startGP);
                      myMapView.setBuiltInZoomControls(true);
                      myMapView.displayZoomControls(true);

                     }

                     @Override
                     protected boolean isRouteDisplayed() {
                      // TODO Auto-generated method stub
                      return false;
                     }

                     private String[] getDirectionData(String srcl, String desl) {

                      String urlString = "http://maps.google.com/maps?f=d&amp;hl=en&amp;saddr="
                       + srcl + "&amp;daddr=" + desl
                       + "&amp;ie=UTF8&amp;0&amp;om=0&amp;output=kml";

                      Log.d("URL", urlString);
                      Document doc = null;
                      HttpURLConnection urlConnection = null;
                      URL url = null;
                      String pathConent = "";

                      try {

                       url = new URL(urlString.toString());
                       urlConnection = (HttpURLConnection) url.openConnection();
                       urlConnection.setRequestMethod("GET");
                       urlConnection.setDoOutput(true);
                       urlConnection.setDoInput(true);
                       urlConnection.connect();
                       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                       DocumentBuilder db = dbf.newDocumentBuilder();
                       doc = db.parse(urlConnection.getInputStream());

                      } catch (Exception e) {
                      }

                      NodeList nl = doc.getElementsByTagName("LineString");
                      for (int s = 0; s &lt; nl.getLength(); s++) {
                       Node rootNode = nl.item(s);
                       NodeList configItems = rootNode.getChildNodes();
                       for (int x = 0; x &lt; configItems.getLength(); x++) {
                        Node lineStringNode = configItems.item(x);
                        NodeList path = lineStringNode.getChildNodes();
                        pathConent = path.item(0).getNodeValue();
                       }
                      }
                      String[] tempContent = pathConent.split(" ");
                      return tempContent;
                     }

                    public class DirectionPathOverlay extends Overlay {

                        private GeoPoint gp1;
                        private GeoPoint gp2;

                        public DirectionPathOverlay(GeoPoint gp1, GeoPoint gp2) {
                            this.gp1 = gp1;
                            this.gp2 = gp2;
                        }

                        @Override
                        public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
                                long when) {
                            // TODO Auto-generated method stub
                            Projection projection = mapView.getProjection();
                            if (shadow == false) {

                                Paint paint = new Paint();
                                paint.setAntiAlias(true);
                                Point point = new Point();
                                projection.toPixels(gp1, point);
                                paint.setColor(Color.BLUE);
                                Point point2 = new Point();
                                projection.toPixels(gp2, point2);
                                paint.setStrokeWidth(2);
                                canvas.drawLine((float) point.x, (float) point.y, (float) point2.x,
                                        (float) point2.y, paint);
                            }
                            return super.draw(canvas, mapView, shadow, when);
                        }

                        @Override
                        public void draw(Canvas canvas, MapView mapView, boolean shadow) {
                            // TODO Auto-generated method stub

                            super.draw(canvas, mapView, shadow);
                        }

                    }
            }
</code></pre>
