Reputation: 56727
In my app I need to upload data periodically to a server if data to be uploaded is available. This doesn't need to happen right away, but can also be delayed for a couple of minutes. WorkManager
seems to be a good starting point from what I've read about it.
I'm now unsure which way to choose:
I could schedule a one-time job every time I have something to upload and have the WorkManager
retry if the upload fails.
I could schedule a periodic job that checks whether there is work to do and if so, does the work.
Both solutions seem to have their pros and cons. The choice depends on some questions I still have:
EDIT
OK, I just found a blog post that stated that WorkManager
ensures that the work is done even if the app or the device is restarted. I'm going to give it a try and see what happens. Still, feel free to answer my questions so I can sleep better...
Upvotes: 1
Views: 269
Reputation: 132
One more point to note in your use case that to make sure you are using a unique periodic work concept otherwise you will have multiple periodic works running around unnecessarily.
Upvotes: 1