JobScheduler 和 JobIntentService

JobScheduler and JobIntentService

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

我最近遇到了 API 26 中引入的 JobIntentService。文档说 "When running on Android O or later, the work will be dispatched as a job via JobScheduler.enqueue. When running on older versions of the platform, it will use Context.startService."

我想了解的是,为什么 android 仅从 API 26 而不是从 API 21 使用 JoScheduler。[=20= 上的 JobScheduler 有区别吗? ] 26 及更高版本 API 21. 我是否需要更改任何代码以改进 efficiency/avoid 错误,将我的后台作业转换为使用 JobIntentService 而不是 Job Scheduler。我想我不明白 JobIntentService 试图实现的意图。

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

JobIntentService 旨在替代 IntentService/WakefulBroadcastReceiver 组合,用于可能需要超过一分钟(但少于十分钟)的后台任务,并且您不想使用前台服务。

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

只有 Google 可以回答这个问题,这就是为什么 "why did Developer X make Decision Y?" 形式的问题不适合 Stack Overflow。

请注意,"more than a minute" 问题是由 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.