admin管理员组文章数量:1122832
// Create WorkRequest for TaskSchedulerWorker (Worker A)
OneTimeWorkRequest workRequestA = new OneTimeWorkRequest.Builder(SchedulerWorker.class)
.addTag(TraiQosAppConstants.SchedulerWorker_Tag)
.setInputData(inputData)
.build();
// Create WorkRequest for ReServiceWorker (Worker B)
OneTimeWorkRequest workRequestB = new OneTimeWorkRequest.Builder(ReServiceWorker.class)
.addTag(TraiQosAppConstants.ReServiceWorker_Tag)
.build();
// Chain Worker A and Worker B
WorkManager.getInstance(context)
.beginWith(workRequestA)
.then(workRequestB) // WorkRequest B only executes if WorkRequest A is successful
.enqueue();
The issue is that the app crashes when it tries to execute the second WorkRequest (Worker B). The log shows the following error before the crash:
Setting status to enqueued for 59d83914-fb1f-4f22-804d-e091561fd032 2024-11-20 17:00:19.558 19153-19153 AndroidRuntime
com.package name D Shutting down VM
I've ensured that both workers are correctly implemented and return Result.success() upon successful completion. However, the app still crashes after Worker A finishes, and Worker B is supposed to start.
本文标签: androidWorkManager Chaining Crashes After Executing First WorkRequestStack Overflow
版权声明:本文标题:android - WorkManager Chaining Crashes After Executing First WorkRequest - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311563a1934784.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论