Reputation: 546
is there any way to get all unfinished works from WorkManager from android-jetpack? I know you can get Works by id/tag. But cannot find some way to get all unfinished Works? Thanks for answers :)
Upvotes: 0
Views: 1109
Reputation: 6506
If what you want to achieve is to maintain the order of your work requests, an approach is to use an UniqueWorkRequest
using as ExistingWorkPolicy
the APPEND
one. This creates for you a chain of work:
WorkManager.getInstance(context).enqueueUniqueWork("unique name", ExistingWorkPolicy.APPEND, myOneTimeWorkRequest)
You can find more information in WorkManager's Unique Work guide. Keep in mind that if you cancel a work request in the chain or return failure
from your worker, the all chain is cancelled or marked as failed.
Upvotes: 1