Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use built-in download manager on Android

Tags:

android

I want to develop an application for the android platform that can download some files from my server.

How can i use android's download manager like it is used in the Android market app? I mean, the one when the user downloads something, a download status is shown in the notification bar.

Sorry about my English!

like image 958
Thanh Le Avatar asked Aug 17 '10 08:08

Thanh Le


1 Answers

The one you mean is probably build into the Android market app. So I guess there is no way to easily reuse it but rather you'd have to build a similar one by yourself. You may want to check out the following SO posts for that purpose:

  • Refresh progress bar in notification bar
  • Progress bar in notification bar when uploading image?

Depending on what kind of files you use I found the easiest way to download files from a remote server is to fire an intent like

Intent downloadIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pathToFile));

If the "pathToFile" is an HTTP address to a pdf document for instance, the Browser will automatically start a download which is shown in the notification bar and once it is finished, the user can click on it and (if an according app is installed) the file will be opened.

If you need to further process the downloaded files from within your app, then it's probably better to handle the download by yourself, opening an HTTP connection etc...

like image 119
Juri Avatar answered Nov 02 '22 02:11

Juri