Skip to content

Instantly share code, notes, and snippets.

@Ikhiloya
Created May 26, 2020 14:37
Show Gist options
  • Select an option

  • Save Ikhiloya/875b97d7afebab0fb45f344a37861825 to your computer and use it in GitHub Desktop.

Select an option

Save Ikhiloya/875b97d7afebab0fb45f344a37861825 to your computer and use it in GitHub Desktop.
val periodicSyncDataWork = PeriodicWorkRequest.Builder(BeneficiaryWorker::class.java, 15, TimeUnit.MINUTES)
.addTag(Constant.TAG_SYNC_BENEFICIARY)
.setConstraints(constraints) // setting a backoff on case the work needs to retry
.setBackoffCriteria(
BackoffPolicy.LINEAR,
PeriodicWorkRequest.MIN_BACKOFF_MILLIS,
TimeUnit.MILLISECONDS
)
.build()
getWorkManager()!!.enqueueUniquePeriodicWork(
Constant.SYNC_BENEFICIARY_WORK_NAME,
ExistingPeriodicWorkPolicy.KEEP, //Existing Periodic Work policy
periodicSyncDataWork //work request
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment