Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created September 15, 2019 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdamiu/bdf3165ba7e9230a9b462b7b6eea7c15 to your computer and use it in GitHub Desktop.
Save magdamiu/bdf3165ba7e9230a9b462b7b6eea7c15 to your computer and use it in GitHub Desktop.
BackoffPolicy example
// add initial delay only for OneTimeWorkRequest
val syncOnlyOnce = OneTimeWorkRequestBuilder<SyncWorker>()
.setInitialDelay(15, TimeUnit.MINUTES)
.build()
// backoff delay and policy
val syncOnlyOnce = OneTimeWorkRequestBuilder<SyncWorker>()
.setBackoffCriteria(BackoffPolicy.LINEAR,
OneTimeWorkRequest.MIN_BACKOFF_MILLIS,
TimeUnit.MICROSECONDS)
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment