我正在使用AdvancedWebView
,其中正在下载一个pdf文件。该文件的名称为某个数字(例如12,13,...)。该文件的下载名称为``12.pdf'',但同样,该文件的下载名称为``download.pdf''。两者文件相同,但两次下载时使用了不同的名称。这是我在AdvancedWebView
中使用的代码来处理下载。
@Override
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {
if (AdvancedWebView.handleDownload(this, url, suggestedFilename)) {
// download successfully handled
//Code for handling download
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(LoginActivity.this, "Check file in your downloads folder.", Toast.LENGTH_SHORT).show();
}
else {
// download couldn't be handled because user has disabled download manager app on the device
}
}
谁能告诉我为什么会这样?从桌面访问时,仅下载了一个文件。