Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created July 4, 2019 18:57
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/51b01ef9e2a3993e56819daa765c902a to your computer and use it in GitHub Desktop.
Save magdamiu/51b01ef9e2a3993e56819daa765c902a to your computer and use it in GitHub Desktop.
Apply Constraints on the task
val constraints = Constraints.Builder()
.setRequiresCharging(true)
.setRequiresStorageNotLow(true)
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val syncOnlyOnce = OneTimeWorkRequestBuilder<SyncDataWorker>()
.setConstraints(constraints)
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment