Saturday, October 13, 2018

Job Scheduler in Android API 21(5.0 Lolipop)

Currently, Android System has two main means to schedule tasks :

  1. AlarmManager
  2. JobScheduler API

The latest apps should use the JobScheduler API. When the system is optimizing based on memory, power, connectivity conditions, APPs can still schedule jobs.
JobScheduler always runs in main UI thread: This means we should use run JobScheduler on Thread or AsyncTask

Advantages :

  1. JobScheduler API helps the batch jobs when devices has more resources
  2. JobScheduler API can be used to schedule everything that is not time critical for the user.
  3. The Android System can combine jobs so that battery consumptions can be reduced.
  4. It helps them during the application restart
  5. JobManager makes handling uploads easier as it handles automatically unreliability of the network.


When to use JobScheduler :
  1. Tasks that require WIFI or Data Connection
  2. Tasks that are not critical or not facing
  3. Tasks that should be running on a regular basis as batch where the time is not critical.
How to use JobScheduler

0 comments:

Post a Comment