I need help designing a solution to a problem specific to long running background tasks.
Background:
- I have an app with activity that displays a list of files.
- The files can each be downloaded. Each downloaded file can have an update.
- The updates, if any, are fired as notifications with update now button. The app has an activity that shows the updates for each file.
- Clicking on update now in either place triggers a background job downloading the file and update the progress in UI in both the places (depending on where the user is).
- The user can update/download a max of 4 files simultaneously.
Design:
- I have a GCM setup with WakefulBroadcastReceiver, that starts a IntentService to notify any updates.
- The update/download is a Runnable - DownloadRunnable.java
- A singleton class, MyDownloadManager has a static method startDownload() that starts the DownloadRunnable with a specific url.
Problem:
- How do I update the progress in both notifications and activity while downloading the update?
- How do I extend the design to run concurrent downloads and update progress to the corresponding item?