Currently, I\'m using WorkManager 1.0.0-alpha02.
def work_version = \"1.0.0-alpha02\"
implementation \"android.arch.work:work-runtime:$work_version\" // use -ktx
The answer from @ianhanniballake is of course helpful and correct, but I thought I'd point out that (with a fast-evolving API) there is a new enqueueUniqueWork() method so I guess the OP could now use:
workManager.enqueueUniqueWork(
SyncWorker.TAG,
ExistingWorkPolicy.REPLACE,
oneTimeWorkRequest
);
beginUniqueWork()
returns a WorkContinuation object. You need to call enqueue
on that WorkContinuation
to actually enqueue it with WorkManager:
workManager.beginUniqueWork(
SyncWorker.TAG,
ExistingWorkPolicy.REPLACE,
oneTimeWorkRequest
).enqueue();