cause the android build in downloadmanager is not reachable by sdk applications i have to implement one by myself. Before starting i want to get feedback how to make it the best way. So here we go:
Requirements:
basic:
Listview with one download per row
button to cancel active downloads
progress view of the downloads
(and so on)
(no questions so far)
I have to reach the downloadmanager from my main activity, start a download -> change to downloadmanager activity and then change back to the main activity but the downloadactivity should stay in the background downloading.
So whats the best way implementing this? Is it possible to keep an activity active in the background, then i could use asynctask to download the files. If not, is it better to use a service and reach that service by the downloadmanager activity so i can close the activity while downloading.
Would be nice to get some input from the experts cause i’m still a beginner.
Thank you
I would recommend that you use a
Servicerather than anAsyncTaskto do your downloading. It is not possible to keepActivity“active in the background”; this is precisely what aServiceis for.Your
Activitywould bind to theServiceand could poll it using an AIDL interface to determine the progress of the downloads.If you’re going to write a
Servicethis blog post on how the Services API changed in Android 2.0 will probably be pretty helpful.