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
JobIntentServiceis 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.
JobIntentServicefor initial sync, and subsequent syncs
DownloadManagerfor all mp3 downloads
- Maybe, in the future use a
SyncAdapterfor 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.