JobIntentService的onHandleWork()的最长作业执行时间是多少?

编程入门 行业动态 更新时间:2024-10-28 05:20:03
本文介绍了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()的最长作业执行时间是多少?

本文发布于:2023-11-04 01:30:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   执行时间   最长   JobIntentService   onHandleWork

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!