Created
March 10, 2019 14:30
-
-
Save aruke/c41016b11247b2a1227c051ac7f4e264 to your computer and use it in GitHub Desktop.
Gists to embed in WorkManager blog. Full code is available at https://github.com/aruke/WorkManagerDemo.
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
class SimpleWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { | |
private val delayInSeconds: Int = workerParams.inputData.getInt(KEY_DELAY, 0) | |
override fun doWork(): Result { | |
// Do intensive task here | |
// For now, our old friend Thread.sleep can replace intensive task here. | |
Thread.sleep(delayInSeconds * 1000L) | |
// Return with success | |
return Result.success() | |
} | |
companion object { | |
const val KEY_DELAY = "com.quipper.wmdemo.DELAY" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment