Last active
June 26, 2022 23:37
-
-
Save akueisara/0859ef41ce8aed13d61abaa5b7cdd1f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val constraints = Constraints.Builder() | |
.setRequiresCharging(true) | |
.build() | |
val work = PeriodicWorkRequestBuilder<MyWorker>( | |
// repeatInterval (the period cycle), its minimum is 15 minutes | |
1, TimeUnit.HOURS, | |
// flexInterval, its minimum is 5 minutes | |
15, TimeUnit.MINUTES) | |
.setConstraints(constraints) | |
.build() | |
val workManager = WorkManager.getInstance(context) | |
workManager.enqueuePeriodicWork(work) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment