Im investigating Android Workers.
api "androidx.work:work-runtime:2.6.0-alpha01"
Im creating unique work that entails multiple workers running in sequence
Worker_A -> Worker_B -> Worker_C
In the event either Worker_A
or Worker_B
returns Result.failure()
is there any approach I can take to detect this within Worker_C
As explained in WorkManager's Chaining Work documentation:
Chains of
OneTimeWorkRequest
execute sequentially as long as their work completes successfully (that is, they return aResult.success()
). Work requests may fail or be cancelled while running, which has downstream effects on dependent work requests.
To answer your question:
In the event either
Worker_A
orWorker_B
returnsResult.failure()
is there any approach I can take to detect this withinWorker_C
?
No, Worker_C
cannot detect a failure of Worker_A
or Worker_B
because it is not going to be run at all.
Chaining and Worker statuses covers this in detail.