Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Last active July 4, 2019 18:16
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/6b3ab19efe93c9591ae6d07d1545de23 to your computer and use it in GitHub Desktop.
Save magdamiu/6b3ab19efe93c9591ae6d07d1545de23 to your computer and use it in GitHub Desktop.
Defining the type of the Worker
val syncOnlyOnce = OneTimeWorkRequestBuilder<SyncWorker>().build()
val syncPeriodically = PeriodicWorkRequestBuilder<SyncWorker>(1, TimeUnit.HOURS).build()
val periodicRefreshRequest = PeriodicWorkRequest.Builder(
SyncWorker::class.java, // the worker class
30, // repeating interval
TimeUnit.Minutes,
15, // flex interval - worker will run somehow within this period of time, but at the end of repeating interval
TimeUnit.MINUTES
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment