无法使用AsyncHttpClient从服务器获取响应

时间:2016-09-14 11:21:49

标签: java android web-services asynchttpclient

我是AsyncHttpClient的新手,我无法实现AsyncHttpResponseHandler。每当我实现它时,我必须覆盖onSuccess和onFailure上的2个方法。

这两种方法都是以下参数: -

client.get(cityURL, new AsyncHttpResponseHandler() {
    @Override
    public void onSuccess(int i, cz.msebera.android.httpclient.Header[] headers, byte[] bytes) {

    }

    @Override
    public void onFailure(int i, cz.msebera.android.httpclient.Header[] headers, byte[] bytes, Throwable throwable) {

    }

我在“cz'说不能识别符号' cz'。我尝试添加以下依赖项: -

  
      
  1. 编译' com.loopj.android:android-async-http:1.4.9'
  2.   
  3. 编译' org.apache.httpcomponents:httpcore:4.4.1'
  4.   

但如果我使用它们同步失败。任何有关这方面的帮助将非常感激。

1 个答案:

答案 0 :(得分:1)

build.gradle

中添加此依赖项
dependencies {
  compile "cz.msebera.android:httpclient:4.4.1.2"
}