首页 > android-async-http 库的使用问题?

android-async-http 库的使用问题?

正在学习android-async-http 这个库,我把官网的代码拷了过来想测试一些就报错,麻烦给看看哪里有问题了啊?新手不懂

代码

package com.example.fiz.myapplication;

/**

import android.util.Log;

//import com.loopj.android.http.AsyncHttpClient;
//import com.loopj.android.http.FileAsyncHttpResponseHandler;
//import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.*;

import java.io.File;

public class Demo {

private void downloadFile(final String url, final String path){

    AsyncHttpClient client = new AsyncHttpClient();
    client.get("https://www.google.com", 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
        }
    });
}

}

截图

Header也找不到


看了源码,他依赖这以下这个库
在glade 中加入

dependencies {
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'cz.msebera.android:httpclient:4.3.6'
}

代码中
import cz.msebera.android.httpclient.Header


缺少 一个包 如果用 gradle

dependencies { 
compile 'com.loopj.android:android-async-http:1.4.9' 
compile 'cz.msebera.android:httpclient:4.4.1.1' 
}

如果不用就去搜索 cz. msebera ....这个包

【热门文章】
【热门文章】