Answer the question
In order to leave comments, you need to log in
How to get Result.failure() from Worker?
I can't use Observer, only ListenableFuture
There is a comment in the sources The {@link State.FAILURE} state will come through as a {@link Throwable} on the {@link ListenableFuture}.
But where to intercept this Throwable is not clear.
val request = OneTimeWorkRequest.Builder(MyWorker::class.java)
.build()
val result = WorkManager.getInstance(App.instance).enqueue(request)
try {
result.result.addListener({
},
{it.run()})
} catch (e: Throwable) {
e.printStackTrace()
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question