StupidBeauty
Read times:1631Posted at: - no title specified

Android-async-http/1.4.6文档翻译:类AsyncHttpResponseHandler,Class AsyncHttpResponseHandler

 AsyncHttpClient client = new AsyncHttpClient();

 client.get("http://www.google.com", new AsyncHttpResponseHandler() {

@Override

public void onStart() {

// 已经将该请求初始化

     }

@Override

public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {

// 成功获取到回复

     }

@Override

public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable

 error)

 {

// 请求失败 :(

     }

@Override

public void onRetry(int retryNo) {

// 已经对请求进行重试

     }

@Override

public void onProgress(int bytesWritten, int totalSize) {

// 进度报告

     }

@Override

public void onFinish() {

// 请求已完成(或者是成功,或者是失败)

     }

 });

      • •. 方法详情

        public void onProgress(int bytesWritten,

        int totalSize)

        当请求的进度发生变化时会调用此方法,重载此方法以在妳自己的代码中处理此事件

        参数

        bytesWritten  - 相对 于文件开头的偏移值

        totalSize  - 文件 的总大小

        public abstract void onSuccess(int statusCode,

        org.apache.http.Header[] headers,

        byte[] responseBody)

        当请求成功完成时会调用此方法,重载此方法以在妳自己的代码中处理此事件

        参数

        statusCode  - 响应内容 中的状态码

        headers  - 所返回的协议头,如果有的话

        responseBody  - 服务器 发来的HTTP 回复的内容体

        public abstract void onFailure(int statusCode,

        org.apache.http.Header[] headers,

        byte[] responseBody,

        java.lang.Throwable error)

        当请求失败时会调用此方法,重载此方法以在妳自己的代码中处理此事件

        参数

        statusCode  - 所返回的 HTTP状态

        headers  - 所返回的协议头,如果有的话

        responseBody  - 所返回的内容体,如果有的话

        error  - 此次失败的底层原因

Your opinions

Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands