Android AsyncHttpClient 下載檔案 Content-Type not allowed! 錯誤
阿新 • • 發佈:2018-11-02
專案開發更新版本時候下載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();
};
} );