Daniyar

Photo by Hush Naidoo on Unsplash

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

git link

Constraints

In onCreate(…) function of MainActivity.kt create Constraints Builder and add it to OneTimeWorkRequest object:

git link

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:

--

--

Daniyar

Daniyar

Google Certified Associate Android Developer