gpt4 book ai didi

android - JobScheduler 和 JobIntentService

转载 作者:太空宇宙 更新时间:2023-11-03 11:54:30 27 4
gpt4 key购买 nike

我正在开发一款支持 Android API 版本 21 及更高版本的应用。我的大部分后台任务都是使用 API 21 中引入的 JobScheduler 设计的。

我最近遇到了 API 26 中引入的 JobIntentService。文档说“在 Android O 或更高版本上运行时,工作将通过 JobScheduler.enqueue 作为作业进行调度。在旧版本平台上运行时,它将使用 Context.startService。”

我想了解的是,为什么 android 仅从 API 26 而不是 API 21 使用 JoScheduler。API 26 及更高版本的 JobScheduler 与 API 21 中引入的 JobScheduler 有区别吗?我需要更改任何代码以提高效率/避免错误,将我的后台作业转换为使用 JobIntentService 而不是作业调度程序。我想我不明白 JobIntentService 试图实现的 Intent 。

最佳答案

I do not understand the intention of what JobIntentService is trying to achieve

JobIntentService 旨在替代 IntentService/WakefulBroadcastReceiver 组合,用于可能需要一分钟以上的后台任务(但少于 10 个)并且您不希望为其使用前台服务。

why android is using JoScheduler only from API 26 and not from API 21

只有谷歌可以回答这个问题,这就是为什么问题的形式是“为什么开发者 X 做出了 Y 的决定?”对 Stack Overflow 不利。

请注意,“超过一分钟”的问题是由 API 级别 26+ 的背景限制引起的;在以前的版本中,没有这样的限制。

Is there a difference in JobScheduler on API 26 and above from that of the one introduced in API 21

有一些变化,包括一些使 JobIntentService 能够工作的扩展。

Do I need to change any code to improve efficiency/avoid mistakes, converting my background jobs to use JobIntentService instead of Job Schedulers

我不知道您为什么要从自己的 JobService 切换到 JobIntentServiceJobIntentServiceIntentService 的替代品,而不是 JobService

关于android - JobScheduler 和 JobIntentService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48268657/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com