开发者

Downloadmanager Concept

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 开发者_StackOverflow社区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 Service rather than an AsyncTask to do your downloading. It is not possible to keep Activity "active in the background"; this is precisely what a Service is for.

Your Activity would bind to the Service and could poll it using an AIDL interface to determine the progress of the downloads.

If you're going to write a Service this blog post on how the Services API changed in Android 2.0 will probably be pretty helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜