Android WorkManager Ensure Only One Active Work (No parallel duplicate)

December 27, 2018
val work = OneTimeWorkRequestBuilder<ProcessImageWithPagingWorker>()
                // .addTag(WORK_NAME)
WorkManager.getInstance().enqueueUniqueWork(WORK_NAME, ExistingWorkPolicy.REPLACE, work)

enqueueUniqueWork This method allows you to enqueue work requests to a uniquely-named WorkContinuation, where only one continuation of a particular name can be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.

The uniqueWorkName uniquely identifies this WorkContinuation.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.