Search in sources :

Example 6 with HttpUtils

use of com.lidroid.xutils.HttpUtils in project xUtils by wyouflf.

the class HttpFragment method testGet.

//@OnClick(R.id.download_btn)
public void testGet(View view) {
    //RequestParams params = new RequestParams();
    //params.addHeader("name", "value");
    //params.addQueryStringParameter("name", "value");
    HttpUtils http = new HttpUtils();
    http.configCurrentHttpCacheExpiry(1000 * 10);
    http.send(HttpRequest.HttpMethod.GET, "http://www.baidu.com", //params,
    new RequestCallBack<String>() {

        @Override
        public void onStart() {
            resultText.setText("conn...");
        }

        @Override
        public void onLoading(long total, long current, boolean isUploading) {
            resultText.setText(current + "/" + total);
        }

        @Override
        public void onSuccess(ResponseInfo<String> responseInfo) {
            resultText.setText("response:" + responseInfo.result);
        }

        @Override
        public void onFailure(HttpException error, String msg) {
            resultText.setText(msg);
        }
    });
}
Also used : HttpUtils(com.lidroid.xutils.HttpUtils) HttpException(com.lidroid.xutils.exception.HttpException)

Aggregations

HttpUtils (com.lidroid.xutils.HttpUtils)6 HttpException (com.lidroid.xutils.exception.HttpException)4 RequestParams (com.lidroid.xutils.http.RequestParams)3 File (java.io.File)3 DbException (com.lidroid.xutils.exception.DbException)1 ResponseStream (com.lidroid.xutils.http.ResponseStream)1