Currently i'm developing an app that needs to synchronize data to the server, every 15 minutes and manual if the sync button is pressed. The issue i'm facing at the moment is that syncs are not queued. A manual sync job can run at the same time as an automatically triggered one, and this should not be possible. The sync will go wrong if the same data is send twice at the same time.
I've tried JobService and WorkManager, but can't really think of a right solution. I've created a PeriodicWorkRequest and a OneTimeWorkRequest. They should queue, and run after the active task is finished.
Any thoughts?
I fixed it like this. I think this should work:
background scheduling:
foreground / active sync:
To manage background and foreground syncs: