Downloading Audio file from a URL

Downloading an audio file from a URL is a very common process and most of the app have this functionality. It is really simple to download an audio from a URL and for that, you need to create an object of DownloadManager and enqueue the DownloadManager.Request object into it.

As you can see in the above code segment a download service is taken and an object of DownloadManager.Request is created with the file URI. You can use the setTitle and setDescription function to the title and description respectively which will be displayed when the notification bar is expanded.

function setDestinationInExternalPublicDir is used to set the destination of the file in the external memory. Environment.DIRECTORY_DOWNLOADS defines that the file will be stored in the downloads directory.

After creating the request all you need to do is use the enqueue function of the DownloadManager to start the download.

 

Thank you very much, this is Vedesh Kumar signing off.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close