title: how to use method in AsyncTask in android?
body: <p>In my application I use <code>JSON</code> webservice to get data from <code>Google Navigation api</code>. I use the code is below. 
  I got the following exception </p>
  
  <p><code>android.os.NetworkOnMainThreadException</code>.</p>
  
  <p>How to use AsyncTask? here is my code. Thanks.`public class MainActivity extends MapActivity {</p>
  
  <pre><code>  MapView mapView ;
  
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
  
      System.out.println("*************1**************1");
      setContentView(R.layout.activity_main);
      System.out.println("*************2**************");
      mapView = (MapView) findViewById(R.id.mapv); 
      System.out.println("*************3**************");
  
  
  
                  Route route = directions(new GeoPoint((int)(26.2*1E6),(int)(50.6*1E6)), new GeoPoint((int)(26.3*1E6),(int)(50.7*1E6)));
  
                RouteOverlay routeOverlay = new RouteOverlay(route, Color.BLUE);
                mapView.getOverlays().add(routeOverlay);
              mapView.invalidate();
  
  
      System.out.println("*************4**************");
  
  }
  
  
  
  @SuppressLint("ParserError")
  private Route directions(final GeoPoint start, final GeoPoint dest) {
  
  
  
      //https://developers.google.com/maps/documentation/directions/#JSON &lt;- get api
      String jsonURL = "http://maps.googleapis.com/maps/api/directions/json?";
      final StringBuffer sBuf = new StringBuffer(jsonURL);
      sBuf.append("origin=");
      sBuf.append(start.getLatitudeE6()/1E6);
      sBuf.append(',');
      sBuf.append(start.getLongitudeE6()/1E6);
      sBuf.append("&amp;destination=");
      sBuf.append(dest.getLatitudeE6()/1E6);
      sBuf.append(',');
      sBuf.append(dest.getLongitudeE6()/1E6);
      sBuf.append("&amp;sensor=true&amp;mode=driving");
  
      Parser parser = new GoogleParser(sBuf.toString());
        Route   r =  parser.parse();
     System.out.println("********r in thread*****" +r);                  
              return r;
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  @Override
  protected boolean isRouteDisplayed() {
      // TODO Auto-generated method stub
      return false;
  }
  </code></pre>
  
  <p>}
  `</p>