如何获得JobInfo的实际状态?

发布于 2025-01-19 03:43:26 字数 644 浏览 3 评论 0原文

类似于workInfo, https://developer.android.com/reference.com/reference.com/reference/androidx/- work/workinfo.state ,我们如何确定JobInfo的实际状态?

我的用例:我有2个工作 - 工作1在充电器上定期运行,工作2在其他各种条件(不是周期性或充电器上)运行。这两个作业都更新了相同的数据库。我想确保工作1在运行2时实际运行。

来自我可以使用getPendingJob,但这只会告诉我是否安排了工作,我想对当时的工作有更好的了解。

Similar to WorkInfo, https://developer.android.com/reference/androidx/work/WorkInfo.State, how can we determine the actual state of JobInfo?

My use case: I have 2 jobs - Job 1 runs periodically on the charger, Job 2 runs for other various conditions (not periodic or on the charger). Both jobs update the same database. I'd like to ensure Job 1 is not actually running when Job 2 runs.

From the docs, it looks like I can use getPendingJob, but that will only tell me if the job is scheduled, and I'd like to have a better idea of what the job is doing at that given moment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文