【问题标题】:what is the maximum job execution time of onHandleWork() of JobIntentService?JobIntentService 的 onHandleWork() 的最大作业执行时间是多少?
【发布时间】:2018-03-13 11:11:36
【问题描述】:

在使用JobIntentService 时,我在使用targetSDK 26 的Android 8 上遇到SecurityException 崩溃。

这是来自 JobIntentService 文档:

那么,JobExecution 的最大时间限制是多少 - 如果我们超过它 - 是否有可能引发 SecurityException?

Security Exception issue tracker

干杯

【问题讨论】:

  • "JobExecution 的最大时间限制是多少" -- 10 分钟,硬编码到 JobService 实现中,至少对于 Android 8.x。 “如果我们超过它 - 是否有可能抛出 SecurityException ?” - 这些问题似乎不是由超过 10 分钟的限制引起的。但是,我还没有测试过如果你尝试跑超过 10 分钟会发生什么。

标签: android


【解决方案1】:

我手动测试过,最大执行时间是600秒,也就是10minutes。接下来会发生什么,JobIntentService 被销毁,然后重新创建以恢复其余工作。这已经从 Android Marshmallow 到 Android Oreo 进行了测试。我也没有遇到任何抛出的异常,我也在使用Thread.sleep()的方法来模拟一个漫长的过程。

更新 1: 我注意到,一段时间后服务停止或 Android 将其置于睡眠状态。因此,假设您在后台进行持续检查,即 API 调用以获取最新数据以推送通知。它工作了一段时间,然后在一两天后停止。我不确定它为什么会随机停止。

【讨论】:

    猜你喜欢
    • 2020-05-15
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多