Issue
I'm trying to use ExistingWorkPolicy
to make some code run that needs to be unique and run to completion only one time.
The documentation of ExistingWorkPolicy of REPLACE
and KEEP
talking about pending (uncompleted) work
. But the documentation of Work States only talks about Enqueued
, Running
, Cancelled
, Failed
, and Succeeded
.
I want to know what exactly does pending
or uncompleted
means in this context?
Solution
pending (uncompleted) work
means everything that is not in the completed
state. Cancelled
, Failed
, and Succeeded
are completed
states.
Edit
If another WorkRequest will be enqueued with REPLACE policy WorkManager
guide states that currently running worker will be stopped and the new one will replace it.
The actual killing of the worker will be dependant on its implementation.
Any ListenableWorker
descendant will receive ListenableWorker.onStopped()
to clean up after itself
Answered By - Pavlo Ostasha