Hi I could not find any thread on stackoverflow regarding difference between GCMNetworkManager and JobScheduler in Android.
Can anyone help me for this.
As mentioned in the previous section, WorkManager internally uses the JobScheduler API on Android 6.0 (API Level 23 – Marshmallow) and above devices. Therefore, there won't be any major differences between the WorkManager and JobScheduler on Android 6.0 and above devices. Both would behave in the same way.
android.app.job.JobScheduler. This is an API for scheduling various types of jobs against the framework that will be executed in your application's own process. See JobInfo for more description of the types of jobs that can be run and how to construct them.
Use WorkManager for reliable workWorkManager is intended for work that is required to run reliably even if the user navigates off a screen, the app exits, or the device restarts. For example: Sending logs or analytics to backend services. Periodically syncing application data with a server.
- [Narrator] Android's WorkManager architecture is designed to handle deferrable, long-running tasks. When you set up a task, it's guaranteed to run whenever the constraints you defined are satisfied.
Both do the same thing, the difference is when you can use or the other.
JobScheduler
was introduced on API 21 as part of the Android framework. If your app minimum API level is 21, you should use this one.
GCMNetworkManager
is a "compat" version of it that is proocessed/executed via Google Play Services (so it works on device). If your app minimum API level is less than 21, you should use this one.
Also important to note, is that GCMNetworkManager have been replaced by FireBase JobDispatcher (https://github.com/firebase/firebase-jobdispatcher-android), so you shouldn't use GCMNetworkManager anymore and use this one instead.
The single solution for scheduling background work is now WorkManager: https://developer.android.com/topic/libraries/architecture/workmanager
Under the hood, WorkManager detects what API level your app is running on and uses JobScheduler (for API 23+) or AlarmManager + BroadcastReceiver (for API 14-22).
Uses JobScheduler for API 23+ Uses a custom AlarmManager + BroadcastReceiver implementation for API 14-22
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With