AsyncHttpResponseHandler类必须声明为abstract或实现抽象方法android

时间:2015-04-22 12:25:10

标签: java android web-services restful-url

https://issues.jboss.org/browse/RF-1236

但是我在下面的代码中得到错误AsyncHttpResponseHandler说AsyncHttpResponseHandler类必须声明为abstract或实现抽象方法android

client.get(“Following this tutorial”,params,new AsyncHttpResponseHandler ()

1 个答案:

答案 0 :(得分:2)

official doc开始,正确的实现是:

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

    @Override
    public void onStart() {
        // called before request is started
    }

    @Override
    public void onSuccess(int statusCode, Header[] headers, byte[] response) {
        // called when response HTTP status is "200 OK"
    }

    @Override
    public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
        // called when response HTTP status is "4XX" (eg. 401, 403, 404)
    }

    @Override
    public void onRetry(int retryNo) {
        // called when request is retried
    }
});