简体   繁体   English

WorkManager 停止状态

[英]WorkManager stopped status

I have a WorkManager that I use to sync my data.我有一个用于同步数据的 WorkManager。 I'm sending both a PeriodicWorkRequest and a OneTimeWorkRequest to Worker.我正在向 Worker 发送PeriodicWorkRequestOneTimeWorkRequest But when I send OneTimeWorkRequest, the status of SystemJobService appears to be stopped.但是当我发送 OneTimeWorkRequest 时,SystemJobService 的状态似乎已停止。 This way work manager works fine but I don't know if it's correct to show as stopped .这种方式工作经理工作正常,但我不知道显示为stopped是否正确。

Background Task Inspector looks like this后台任务检查器看起来像这样在此处输入图像描述

OneTimeWorkRequest and PeriodicWorkRequest have different state logic. OneTimeWorkRequest 和 PeriodicWorkRequest 具有不同的 state 逻辑。

As you saw, once a OneTimeWorkRequest is completed with a Success, Failure or Cancellation.如您所见,一旦 OneTimeWorkRequest 以 Success、Failure 或 Cancellation 完成。 It is marked as stopped.它被标记为已停止。

WorkManager's documentation covers this topic . WorkManager 的文档涵盖了这个主题

For PeriodicWorkRequest, the only way to stop it, is a Cancellation.对于 PeriodicWorkRequest,停止它的唯一方法是取消。 A Success or Failuire, simply re-enqueue the WorkRequest.成功或失败,只需将 WorkRequest 重新入队即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM