gpt4 book ai didi

java - Android Java - 下载管理器未使用正确的名称保存

转载 作者:行者123 更新时间:2023-12-02 01:44:37 26 4
gpt4 key购买 nike

几乎一切都工作正常,但是当我在“下载”下下载文件时,它被保存为“Download-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);
}
}

我如何才能使用我的客户头衔?

最佳答案

更新:

我通过改变这个让它工作:

request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");

request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, item.DisplayName +".mp3");

这可能会对某人有所帮助。

关于java - Android Java - 下载管理器未使用正确的名称保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53869838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com