I want to detect, how long a specific work is already in enqueue
mode. I need this information, in order to inform the user about his state (e.g when workmanager is longer than 10 seconds in enqueue mode
-> cancel work -> inform user that he needs to do X in order to achieve Y). Something like this:
Pseudo Code
workInfo.observe(viewLifecylceOwner) {
when(it.state) {
WorkInfo.State.ENQUEUED -> if(state.enqueue.time > 10) cancelWork()
}
}
I didn't find anything about this anywhere. Is this possible?
I appreciate every help.
I have managed to create a somewhat robust "Workmanager watcher". My intention was the following: When the Workmanager is not finished within 7 seconds, tell the user that an error occurred. The Workmanager itself will never be cancelled, furthermore my function is not even interacting with the Workmanager itself. This works in 99% of all cases:
Workerhelper
Then in my Workmanager.enqueueWork function:
And finally in my ViewModel
I've also created a function that converts the Status of my
workmanager
to my custom status class:Status
Function