I'm developing an Android app, and it has 3 different cases of network use. Once configured, it needs to do a potentially long-running process of syncing the local database with a remote one. Later, it will need to check for updates from the remote DB and sync to the local DB, but they will usually be small.

The main activity isn't really usable until the first sync is complete. I want to show a notification on the sync progress, and/or a progress indicator/activity on the app itself if it's in the foreground.

Once sync'd, you can then download remotely hosted MP3s on-demand.

Which Android classes/patterns should I use for a large, user-initiated initial DB sync, any subsequent on-demand mp3 file downloads, and later scheduled small DB syncs? Can I show a progress notification and activity in my app using those any of those classes?


For my 3 use cases the Android API offers these classes/interfaces:

  • DownloadManager - This looks very useful for downloading data files, but the initial sync of my application is basically just parsing multiple huge XML HTTP responses. I'm not sure it's suited for that. Especially since I can split the XML HTTP response as needed, and it's already marshaled by Retrofit.
  • JobIntentService/IntentService/JobScheduler - This looks like what I should use for the initial sync, and also possibly any subsequent syncs. I'm not entirely sure of the differences between them, but it looks like the JobIntentService is the recommended one to use.
  • SyncAdapter - looks promising for later updates, but I would like the initial sync to display a notification with the progress. Is this possible with a SyncAdapter? Any mp3 downloads should be immediately queued and processed, so this does not look applicable for that.
  • AsyncTask - According to the docs, just for short running processes, don't think it's applicable for my usage.
  • Volley - Doesn't seem applicable since I already use Retrofit.

Proposed usage

  • JobIntentService for initial sync, and subsequent syncs
  • DownloadManager for all mp3 downloads
  • Maybe, in the future use a SyncAdapter for subsequent syncs

Is this an OK approach? I am hesitant to ever use a SyncAdapter since it seems to require a lot more work to get the same data as a Job.

  • I've condensed the question down in response to the close vote. Not sure why it was downvoted.– NickFeb 15 at 14:45

Rx java may be a solution if you don't having an extra lib dependency. Rx makes it easy to run long running work on a background thread.

Example can be found herehttps://piercezaifman.com/converting-an-asynctask-to-rxjava/

  • invalid answer since link is no longer active– SiddharthJun 17 at 14:15

Use AsyncTask for that. And place it in a Service.

  • Can you elaborate: For what (initial sync, file download, or resync)? And why in a service? The API docs explicitly state it AsyncTask should not be used for long-running processes (more than a few seconds).– NickFeb 15 at 14:45
  • Long running means can work even when the associated app is closed. Only a service can do that. Now downloading requires that it runs on a separate thread. AsyncTask allows the running in a separate thread without hanging the service. Combining the 2 will do the trick.– Francis Nduba NumbiFeb 18 at 13:02

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.