Android Java-下载管理器未使用正确的名称保存
几乎所有东西都正常工作,但当我在“下载”下下载文件时,它会保存为“下载-1” 这是我使用的代码Android Java-下载管理器未使用正确的名称保存,java,android,Java,Android,几乎所有东西都正常工作,但当我在“下载”下下载文件时,它会保存为“下载-1” 这是我使用的代码 public void download(){ if (_ctx.checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { DownloadManager.Request request = new Down
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.setDestinationNexternalPublicDir(Environment.DIRECTORY_DOWNLOADS,”)代码>
到
request.setDestinationNexternalPublicDir(Environment.DIRECTORY_下载,item.DisplayName+“.mp3”)代码>
这可能对某人有所帮助。更新:
我通过改变这一点来实现:
request.setDestinationNexternalPublicDir(Environment.DIRECTORY_DOWNLOADS,”)代码>
到
request.setDestinationNexternalPublicDir(Environment.DIRECTORY_下载,item.DisplayName+“.mp3”)代码>
这可能对某人有所帮助