Android Download Manager download from url Tutorial

To make your mobile application able to download from http url is majorly use for download mp3 music , images file and apk from websites. Android provide the DownloadManager Object to let android application to download all file from internet that can specific by the developers which can provide better experience to the user. The DownloadManager will conduct the installing process in the background of the application and it is take caring when the connection is failure or system reboots. The broadcastreceiver which can use to combine with download manager for notify downloaded file. In this tutorial, I will teach you how to use android download manager download from url and some other feature of download manager.

Create a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “FileDownloadExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Project” and Click Next button
5. Lastly, press finish button.

Add permissions

Open your AndroidManifest.xml file, adding the internet, read and write external permissions outside the application level so u can access those feature in the application.

Create a new xml item

Res> layout > right click > new > layout resource file and name the resource to down_load_task_item.xml. This layout is to show the downloaded item in the application.

Edit down_load_task_item.xml layout

Go to down_load_task_item and change your source code to the source code that i provided in the below section.

Edit activity_main.xml layout

After that, navigate to your activity_main.xml to edit the main page layout of your android application. It will have 4 basic buttons to perform different actions which are Download, Delete, Download with display progress and Display Downloaded file. The source code will be…

Create a Broadcastreceiver

Java > right click your package name and create a new java class and name it to DownloadCompleteReceiver after that copy and paste the following source code below.

Edit class

Navigate to your class and paste the following source code. In this application will download the mp3 file from the url.

Run your project

Finally, you can run it and download file from the url, you also can check what you are download in your application.

(Android Download Manager download from url)

Source Code

(Visited 1,762 times, 1 visits today)

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *