Created
December 26, 2019 20:52
-
-
Save Lavanyagaur22/659b07bab466896e8ab32fc958b782d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private fun scheduleRepeatingTasks() { | |
/*Setting up different constraints on the work request. | |
*/ | |
val constraints = Constraints.Builder().apply { | |
setRequiredNetworkType(NetworkType.CONNECTED) | |
setRequiresCharging(true) | |
setRequiresStorageNotLow(true) | |
}.build() | |
/*Build up an obejct of PeriodicWorkRequestBuilder | |
*/ | |
val repeatingWork = PeriodicWorkRequestBuilder<NotificationRequestWorker>( | |
1, | |
TimeUnit.DAYS | |
).setConstraints(constraints) | |
.build() | |
/*Enqueue the work request to an instance of Work Manager | |
*/ | |
WorkManager.getInstance(this).enqueue(repeatingWork) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment