JobIntentService与IntentService的区别

JobIntentService与IntentService在Android O之前用于后台任务执行,但在Android O及更高版本中,JobIntentService受JobScheduler策略影响,不会在设备休眠(Doze模式)时立即执行,可能导致延迟,不适合处理即时任务。IntentService则相对不受此限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JobIntentService与IntentService都是可以用来执行后台任务,在Android O之前,使用起来效果没多大差别,但是Android O以后JobIntentService不会立即执行,等手机进入一定状态后才会执行任务,所以不能用来执行及时的后台任务。

When running as a pre-O service, the act of enqueueing work will generally start the service immediately, regardless of whether the device is dozing or in other conditions. When running as a Job, it will be subject to standard JobScheduler policies for a Job with a setOverrideDeadline(long) of 0: the job will not run while the device is dozing, it may get delayed more than a service if the device is under strong memory pressure with lots of demand to run jobs.

the job will not run while the device is dozing 重点是这里的说明。
关于Doze模式的介绍,请参考:
Android中的Doze模式

参考JobIntentService的部分代码:

    @RequiresApi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值