What's a JobScheduler?
The JobScheduler is an Android system service available on API levels 21
(Lollipop)+. It provides an API for scheduling units of work (represented by
JobService subclasses) that will be executed in your app's
Why is this better than background services and listening for system broadcasts?
Running apps in the background is expensive, which is especially harmful when
they're not actively doing work that's important to the user. That problem is
multiplied when those background services are listening for frequently sent
android.hardware.action.NEW_PICTURE are common examples). Even worse, there's
no way of specifying prerequisites for these broadcasts. Listening for
CONNECTIVITY_CHANGE broadcasts does not guarantee that the device has an
active network connection, only that the connection was recently changed.
In recognition of these issues, the Android framework team created the JobScheduler. This provides developers a simple way of specifying runtime constraints on their jobs. Available constraints include network type, charging state, and idle state.
This I/O presentation has more information on why background services can be harmful and what you can do about them:
There's more information on upcoming changes to Android's approach to background services on the Android developer preview page.
The FirebaseJobDispatcher currently relies on the scheduling component in Google Play services. Because of that, it won't work on environments without Google Play services installed.
Comparison to other libraries
|Library||Minimum API||Requires Google Play||Service API1||Custom retry strategies|