几乎所有内容都可以正常运行,但是当我在“下载”下下载文件时,该文件将另存为“下载-1”
这是我正在使用的代码。
public void download(){
if (_ctx.checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
request.setDescription("Downloading " + DisplayName +".mp3");
request.setTitle(DisplayName +".mp3");
request.setMimeType("audio/MP3");
request.setAllowedOverRoaming(false);
request.setVisibleInDownloadsUi(true);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");
DownloadManager downloadManager = (DownloadManager)_ctx.getApplicationContext()
.getSystemService(Context.DOWNLOAD_SERVICE);
downloadManager.enqueue(request);
}
}
我如何使用我的客户名称?
答案 0 :(得分:2)
更新:
我通过更改此方法使其起作用:
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");
到
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, item.DisplayName +".mp3");
这可能会帮助某人。