I am working on an app that supports Android API version 21 and above. Most of my background tasks have been designed with JobScheduler introduced in API 21.
I have recently come across JobIntentService introduces in API 26. The documentation says "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."
What I want to understand is, why android is using JoScheduler only from API 26 and not from API 21. Is there a difference in JobScheduler on API 26 and above from that of the one introduced in API 21. Do I need to change any code to improve efficiency/avoid mistakes, converting my background jobs to use JobIntentService instead of Job Schedulers. I guess I do not understand the intention of what JobIntentService is trying to achieve.
I do not understand the intention of what JobIntentService is trying to achieve
JobIntentService
is meant to be a replacement for the IntentService
/WakefulBroadcastReceiver
combination, for background tasks that might take more than a minute (but less than ten) and for which you do not wish to use a foreground service.
why android is using JoScheduler only from API 26 and not from API 21
Only Google can answer that, which is why questions of the form "why did Developer X make Decision Y?" are not good for Stack Overflow.
Note that the "more than a minute" issue arises with the background limitations on API Level 26+; on previous versions, there was no such limit.
Is there a difference in JobScheduler on API 26 and above from that of the one introduced in API 21
There have been changes, including some extensions that enable JobIntentService
to work.
Do I need to change any code to improve efficiency/avoid mistakes, converting my background jobs to use JobIntentService instead of Job Schedulers
I do not know why you would switch from your own JobService
to JobIntentService
. JobIntentService
is a replacement for IntentService
, not for JobService
.