WorkManager: Beyond the basics (Android Dev Summit '19)

Android Developers · 26K views · 2019 · 18:19

Open on YouTube

Software architecture & designTesting, debugging & developer toolsSoftware (other)talkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering WorkManager questions, especially about background work behavior and how to set up WorkManager for testing with custom worker factories and delays.

Recommended by 0 people across 0 different months, 2020 to 2021.

What it is

An 18-minute Android Dev Summit 2019 session on Jetpack WorkManager, presented by Rahul Ravikumar and Sumir Kataria. It covers intermediate and advanced topics, common gotchas, and issues that appear when deploying background work to a large range of users and devices.

What people said

Cites Mohammed Uzair · 2020-07 · Stack Overflow · on “I want user start long complex backround task and control it's execution in Android. What to use?”

We have MvvM architecture to tackle your problem, the ViewModel(A simple java/kt class) will still have its instance when the activity or fragment changes its configurations like(Device rotated, keyboard attached/detached etc). You can run your long task in viewmodel, and listen to the changes in your activity. Like: -> MyViewModel.kt val longWork = MutableLiveData<String>() fun performLongWork(){ // This is a viewmodel scope, which means, // if the user has left the UI screen, any work that was started within // this scope will finish and not report any result. But if you want to // still continue the work even if the user left the screen, // use CoroutineScope(IO).launch{} viewModelScope.l

Cites Yavor Mitev · 2020-10 · Stack Overflow · on “Android. Is WorkManager running when app is closed?”

Does anyone know what are the ideas in the video around 8:40? The guys are saying: "Come talk to us. We have some ideas". :D [this video]

Cites Rômulo Silva · 2021-10 · Stack Overflow · on “Testing initial delay on CoroutineWorker with Dependencies”

After watching this video [this video] (at 13:00) from the 2019 Android Dev Summit, I found the answer for this question: When initializing workManager for test (by WorkManagerTestInitHelper.initializeTestWorkManager method) , we have to pass our custom WorkerFactory through the configuration step; Setup your request worker as you normally would using the OneTimeWorkRequestBuilder method; By default, all constraints for Workmanager instances in the test mode are unmet. Using an instance of TestDriver , we can mark those constraints as met. Here's an example to summarize these above steps: @Test fun checkInitialDelay() { val config = Configuration.Builder() .setWorkerFactory( MyWorkFactory(myDepen