JobIntentService的onHandleWork()的最长作业执行时间是多少? [英] what is the maximum job execution time of onHandleWork() of JobIntentService?

查看:113
本文介绍了JobIntentService的onHandleWork()的最长作业执行时间是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am encountering a SecurityException crash on Android 8 with targetSDK 26 when using JobIntentService.

这是来自JobIntentService文档:

This is from JobIntentService docs:

那么最大JobExecution时限是多少?如果超过该上限,是否可能引发SecurityException?

So What is the maximumJobExecution time limit - and if we exceed it - will it possible that a SecurityException will be thrown?

安全异常问题跟踪器

欢呼

推荐答案

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

I've manually tested it, the maximum execution time is 600 seconds, which means 10minutes. What happens next, is the JobIntentService gets destroyed, then re-created to resume the rest of the work. This has been tested from Android Marshmallow to Android Oreo . I also haven't experienced any thrown exception, I'm also using Thread.sleep() method to simulate a long process.

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

Update 1: I've noticed, that after a while the service stops or Android puts it to sleep. So let's say, you're doing constant checks in the background i.e. API calls to get latest data to push notifications. It works for a while, then stops after a day or 2. I'm not sure why it randomly stops.

这篇关于JobIntentService的onHandleWork()的最长作业执行时间是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆