简体   繁体   中英

Android WorkManager - get unfinished works from WorkManager

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 :)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM