Reputation: 53
Almost everything is working correctly but when I download my file under "Downloads" it is saved as "Download-1"
Here is the code im using.
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);
}
}
How can i get to use my custome title?
Upvotes: 0
Views: 39
Reputation: 53
Update:
I got it to work by changing this:
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");
to
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, item.DisplayName +".mp3");
This might help someone.
Upvotes: 2