在使用 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()的最长作业执行时间是多少?
发布评论