我有这个代码可以下载图片,但出于某种原因,图片在我的下载中是“排队”而不是下载。
String url = file.public_url;
getContext();
DownloadManager manager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setTitle(file.filename);
request.setDescription(file.filename + " description.");
request.allowScanningByMediaScanner();
request.setAllowedOverRoaming(true);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, file.filename + file.file_extension);
manager.enqueue(request);
答案 0 :(得分:0)
我已使用此Async版本成功下载了不使用DownloadManager的图像https://stackoverflow.com/a/3028660/6136947