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:
JobIntentService
is the recommended one to use.JobIntentService
for initial sync, and subsequent syncsDownloadManager
for all mp3 downloadsSyncAdapter
for subsequent syncsIs 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.
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 here https://piercezaifman.com/converting-an-asynctask-to-rxjava/