简单的 HTTP 请求工具:AndroidHttpTools

jopen 6年前

AndroidHttpTools 是简单的 HTTP 请求工具,支持 get,post,post 文件。

//------------------------简单示例------------------------//

String url = "http://www.baidu.com/";     private void requestData() {      ConnectionHelper conn = ConnectionHelper.obtainInstance();      long requstHandler = conn.httpGet(url, 0, rr);      // support cancel      // conn.cancleRequest(requstHandler);  }     private void reqeustData2() {      ConnectionHelper.obtainInstance().execute(              RequestEntity.obtain().url(url).method(RequestMethod.GET)                      .receiver(rr));  }     private RequestReceiver rr = new RequestReceiver() {         @Override      public void onResult(int resultCode, int reqId, Object tag, String resp) {          if (resultCode == RESULT_STATE_OK) {              // reqeustion ok          } else {              // reqeust error          }      }         @Override      public void onRequestCanceled(int reqId, Object tag) {          // on canceled      }  };

项目主页:http://www.open-open.com/lib/view/home/1405499029968