Ejemplo n.º 1
0
  public void doPost(String url, Map<String, String> params, HttpCallback callback) {
    try {

      HttpPost post = new HttpPost(url);
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(params.size());

      for (String key : params.keySet()) {
        nameValuePairs.add(new BasicNameValuePair(key, params.get(key)));
      }

      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs);
      post.setEntity(entity);

      HttpRequestInfo rinfo = new HttpRequestInfo(post, callback);
      AsyncHttpTask task = new AsyncHttpTask();
      task.execute(rinfo);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 2
0
 public void doGet(String url, HttpCallback callback) {
   HttpGet get = new HttpGet(url);
   HttpRequestInfo rinfo = new HttpRequestInfo(get, callback);
   AsyncHttpTask task = new AsyncHttpTask();
   task.execute(rinfo);
 }