title: Error in calculating distance
body: <p>I found this code for using JSON in calculating distance. I tried to edit it to use it in my project but something went wrong when I click the button. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  EditText e1,e2;
  TextView t1;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      e1 = (EditText) findViewById (R.id.editText1);
      e2 = (EditText) findViewById (R.id.editText2);
      t1 = (TextView) findViewById (R.id.textView1);
  }
  public void d (View view){
      GetRoutDistane(0, 0, 0, 0);
  }
  public String GetRoutDistane(double startLat, double         startLong, double endLat, double endLong)
  {
    String Distance = "error";
    String Status = "error";
    try {
        Log.e("Distance Link : ", "http://maps.googleapis.com/maps/api/directions/json?origin="+ startLat +e1+ startLong +"&amp;destination="+ endLat +e2+ endLong +"&amp;sensor=false");
          JSONObject jsonObj = parser_Json.getJSONfromURL("http://maps.googleapis.com/maps/api/directions/json?origin="+ startLat +e1+ startLong +"&amp;destination="+ endLat +e2+ endLong +"&amp;sensor=false"); 
          Status = jsonObj.getString("status");
          if(Status.equalsIgnoreCase("OK"))
          {
          JSONArray routes = jsonObj.getJSONArray("routes"); 
           JSONObject zero = routes.getJSONObject(0);
           JSONArray legs = zero.getJSONArray("legs");
           JSONObject zero2 = legs.getJSONObject(0);
           JSONObject dist = zero2.getJSONObject("distance");
           Distance = dist.getString("text");
           t1.setText(Distance.toString());
          }
          else
          {
              Distance = "Too Far";
          }
      } catch (JSONException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  return Distance;
  
  
  } 
  public static class parser_Json {
  
      public static JSONObject getJSONfromURL(String url){
  
          //initialize
          InputStream is = null;
          String result = "";
          JSONObject jArray = null;
  
          //http post
          try{
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost(url);
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
  
          }catch(Exception e){
              Log.e("log_tag", "Error in http connection "+e.toString());
          }
  
          //convert response to string
          try{
              BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              result=sb.toString();
          }catch(Exception e){
              Log.e("log_tag", "Error converting result "+e.toString());
          }
  
          //try parse the string to a JSON object
          try{
                  jArray = new JSONObject(result);
          }catch(JSONException e){
              Log.e("log_tag", "Error parsing data "+e.toString());
          }
  
          return jArray;
      }
  
       public static InputStream retrieveStream(String url) {
  
              DefaultHttpClient client = new DefaultHttpClient(); 
  
              HttpGet getRequest = new HttpGet(url);
  
              try {
  
                 HttpResponse getResponse = client.execute(getRequest);
                 final int statusCode = getResponse.getStatusLine().getStatusCode();
  
                 if (statusCode != HttpStatus.SC_OK) { 
  
                    return null;
                 }
  
                 HttpEntity getResponseEntity = getResponse.getEntity();
                 return getResponseEntity.getContent();
  
              } 
              catch (IOException e) {
                 getRequest.abort();
  
              }
  
              return null;
  
           }
      }
  
  }
  </code></pre>
  
  <p>The code didn't give error in Eclipse, but just click on the button leads to a crash.</p>