Android AsyncHttpClient 下载文件 Content-Type not allowed! 错误

项目开发更新版本时候下载apk使用AsyncHttpClient 及BinaryHttpResponseHandler来处理

但总是报errororg.apache.http.client.HttpResponseException: Content-Type not allowed! 错误

以下红色标注为解决方法


String[] allowedContentTypes = new String[] {"application/vnd.android.package-archive"};

httpClient.get(newappurl, new BinaryHttpResponseHandler(allowedContentTypes) {

                       @Override
public void onSuccess(int statusCode, Header[] headers, byte[] binaryData) {

}

@Override
public void onFailure(int statusCode, Header[] headers, byte[] binaryData,
Throwable error) {
ToastUtil.show(getActivity(), error.toString(), 2000);
}


//下载过程监听
public void onProgress(int bytesWritten, int totalSize) {


pd.setMax(totalSize);
pd.setProgress(bytesWritten);
pd.show();


};
} );

猜你喜欢

转载自blog.csdn.net/feitian145623/article/details/51699341
今日推荐