以下是我下载文件的方法,它适用于http,但是当我使用https时,它不会回调,感谢您的帮助。
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(Constant.request_imageFolder + item.user_id + "/" + item.record_url));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
//request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
}
request.setDestinationUri(Uri.fromFile(tmp_record));
enqueue = mgr.enqueue(request);
不完整的代码,当我使用https时不会调用
onComplete = new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
Query query = new Query();
query.setFilterById(enqueue);
if (query != null) {
Cursor c = mgr.query(query);
if (c.moveToFirst()) {
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
String mediaType = c.getString(c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE));
if (mediaType.equals("image/jpeg")) {
pDialog.dismiss();
share.performClick();
} else if (mediaType.equals("video/mp4")) {
pDialog.dismiss();
play();
}
}
}
}
}
}
};
我尝试调试但错误检测消息是在回调中,因此没有关于问题根的提示,只知道它是由https引起的。我该如何解决?谢谢你的帮助?