我在spring框架中开发了一个Web应用程序。在Web应用程序中,下载工作正常,但是对于webview,文件未下载。我从DownloadListener使用Android的onDownloadStart(),但是onDownloadStart()无法正常工作(可能是他没有收到正确的URL)。我正在下载文件的路径(不是确切的URL)。所以这就是他不起作用的原因。
这是我的下载代码
webView.setDownloadListener(new DownloadListener(){
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength)
{
//for downloading directly through download manager
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "download");
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(),"inside download",Toast.LENGTH_LONG).show();
}
});