我想从我的webview下载图片,收到通知并下载文件,但是当我去Gallery时,文件就不存在了。我做错了什么...... ??
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(geturl));
request.setTitle("File Download");
request.setDescription("File is being downloaded...");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
String nameOfFile = URLUtil.guessFileName(geturl, null, MimeTypeMap.getFileExtensionFromUrl(geturl));
request.setDestinationInExternalFilesDir(this,Environment.DIRECTORY_DCIM,nameOfFile);
DownloadManager manager = (DownloadManager)getApplication().getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
虽然geturl是Override url,我通过它获取图像的url。
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//Get url for downloading
geturl = url;
return true;
}