Add workManager dependency, be sure to handle java 8 syntax and add Kotlin notation
Deferrable tasks with WorkManager
Create MyWorker.kt class:
In MainActivity.kt create OneTimeWorkRequest and pass it to the enqueue(…) function of the WorkManager Instance
Constraints
In onCreate(…) function of MainActivity.kt create Constraints Builder and add it to OneTimeWorkRequest object:
Data From Background to UI
Change MyWorker.kt class:
In onCreate(...) function in MainActivity.kt class in Button Click listener add Observer and set received data by key to TextView:
Progress Updates from a Background Worker
In MyWorker.kt add following code:
In onCreate(…) function in MainActivity.kt class in Button Click listener add additional item to "When" Statement:
The result: