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
    }
};
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()