WorkManager beginUniqueWork doesn't work as expected

前端 未结 2 1550
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-14 17:44

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         


        
2条回答
  •  隐瞒了意图╮
    2021-02-14 18:22

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

提交回复
热议问题