Last active
May 26, 2020 14:37
-
-
Save Ikhiloya/25f1b0d199c8d57e14d0bd8d8c6ee016 to your computer and use it in GitHub Desktop.
A worker class to post person data to the remote server
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
| val periodicSyncDataWork = | |
| PeriodicWorkRequest.Builder(PersonWorker::class.java, 15, TimeUnit.MINUTES) | |
| .addTag(Constant.TAG_SYNC_PERSON) | |
| .setConstraints(constraints) // setting a backoff on case the work needs to retry | |
| .setBackoffCriteria( | |
| BackoffPolicy.LINEAR, | |
| PeriodicWorkRequest.MIN_BACKOFF_MILLIS, | |
| TimeUnit.MILLISECONDS | |
| ).build() | |
| getWorkManager()!!.enqueueUniquePeriodicWork( | |
| Constant.SYNC_PERSON_WORK_NAME, | |
| ExistingPeriodicWorkPolicy.KEEP, //Existing Periodic Work policy | |
| periodicSyncDataWork //work request | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment