dTo(new File("/mnt/sdcard/abcd.png"), new VolleyListener<String>() {
@Override
public void onSuccess(String data) {
Log.e("!!!!!", "asImageFile: " + data);
}
@Override
public void onError(int code, String description) {
Log.e("!!!!!", "asImageFile: " + description);
}
});
//设置通用的请求参数或请求头
DVolley.enterGlobalConfig()
.globalParam("t", String.valueOf(System.currentTimeMillis()))
.globalHeader("os", "android");
DVolley组件:https://github.com/woshidasusu/base-module/tree/master/volley
组件有如下两个依赖库:
compile 'com.android.volley:volley:1.1.1'
compile 'com.google.code.gson:gson:2.7'
支持以下功能:
- get 请求
- post 请求
- 图片下载在本地指定目录
- 自动根据泛型解析 json
- 取消指定请求
- 设置通用请求参数或请求头
大家好,我是 dasu,欢迎关注我的公众号(dasuAndroidTv),如果你觉得本篇内容有帮助到你,可以转载但记得要关注,要标明原文哦,谢谢支持~