mLogInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
@Streaming
@GET
final retrofit2.Call<ResponseBody> call = NetWork.getApi(Constant.APP_URL).downloadFile(url);
call.enqueue(new retrofit2.Callback<ResponseBody>() {
@Override
public void onResponse(retrofit2.Call<ResponseBody> call, final retrofit2.Response<ResponseBody> response) {
处理下载
}
-----------------------------------------------------------------------------------
结果onResponse这个函数没有响应了。是坑吗,感觉是有点坑,特此记录。
解决方法,可以
mLogInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
或者不用
共包含四个级别:NONE、BASIC、HEADER、BODY
当设置为BODY时,retrofit 定义下载接口@Streaming
@GET
Call<ResponseBody> downloadFile(@Url String fileUrl);
---------------------------------------------------------------------------------
调用:final retrofit2.Call<ResponseBody> call = NetWork.getApi(Constant.APP_URL).downloadFile(url);
call.enqueue(new retrofit2.Callback<ResponseBody>() {
@Override
public void onResponse(retrofit2.Call<ResponseBody> call, final retrofit2.Response<ResponseBody> response) {
处理下载
}
-----------------------------------------------------------------------------------
结果onResponse这个函数没有响应了。是坑吗,感觉是有点坑,特此记录。
解决方法,可以
mLogInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
或者不用