Reputation: 9057
I'm implementing a DownloadManager-like feature in an application I'm developing. I use AsyncTask to push the download to the background.
This AsyncTask is inside a service named for example DownloadService
which is instantiated on one of my activities. So this means multiple downloads could be started from different instances of an activity.
What I want to do is to have a particular activity in which I can have all the currently running downloads show their progress and have button to pause or resume the download.
Upvotes: 0
Views: 161
Reputation: 23186
Instead of housing DownloadService
inside an Activity, house it inside you app's Application
class as a class member instead, as there will exist only one instance of this class per application. You can then retrieve it in you activity by calling ((YourApplication)getApplication()).getDownloadService()
. You will have to:
<application>
tag as android:name="YourApplication"
((YourApplication)getApplication()).someMethodToGetDownloadService()
Upvotes: 0
Reputation: 5183
In case you want such thing, you can store in an Array all Async Tasks that get started in the service, and then check their status with http://developer.android.com/reference/android/os/AsyncTask.html#getStatus%28%29.
Hope this helps!
Upvotes: 1