Background work with JobScheduler (Android Development Patterns S3 Ep 12)

By: Android Developers

298   12   24802

Uploaded on 09/22/2016

Read the blog post ( for all the details on scheduling background work with JobScheduler, available on Android Lollipop (API 21) and higher. JobScheduler batches jobs together across all apps making it a great choice for conserving battery, reducing overall memory pressure on API 24 and higher, and using JobScheduler means you are automatically aware of Doze and App Standby.

Jobs can be persisted across reboots, scheduled to repeat at a set interval, automatically backoff in response to failures, or scheduled with set requirements such as network connectivity or only when the device is idle.

Learn about all of the mechanisms available for scheduling jobs in the documentation:

#BuildBetterApps #androidn #jobscheduler #battery #adp #background

Comments (7):

By anonymous    2017-09-20

JobScheduler is a great option when you want to trigger some actions that just happens when some preconditions are made (Connectivity, Battery and System's Broadcasts). In you case schedule some work that only happens when the user has internet connection.

You can use JobScheduler minimum API 21 and Google Play Service is NOT required. FirebaseJobDispatcher minimum API 9 and Play Service is REQUIRED.
Additionally AndroidJob is a library that has minimum API 14 and does NOT require Play Service.

This video can help to clarify some doubts with FirebaseJobDispatcher and additionally this post by Evernote is good resource.

Original Thread

By anonymous    2017-09-20


Always start long term operations from a service. (or a JobScheduler)


If you are downloading a reasonably big file, use the presenter to trigger an IntentService (or JobScheduler for Android Marshmallow and later), never AsyncTask, Thread or any asynchronous structure that would callback to the main thread.

The presenter survives to onPause, but not to onDestroy, so if the application be killed by the operating system the reference to the activity/fragment will be lost anyway.

If you are running the download in a service, your presenter can check if the file already exists and updates the activity/fragment properly.

Remember that the fragment being destroyed is actually good for the OS, so use early/often persistence of network data :-)

Original Thread

By anonymous    2017-09-20

What is the best approach to implement a service which executes every 15 mins.

Using the Job Scheduler. Information on job scheduling can be found at the Intelligent Job-Scheduling documentation. However, be aware that you can't be 100% sure that your service is going to run exactly every 15 minutes as its execution can be affected by the Doze mode and its restrictions.

For the notification part, you build your notification as you would normally do.

If you need more info, you may view the Using the Android Job Scheduler and Background work with JobScheduler videos and check this sample project. Also, one relevant question regarding the repetitive nature of the service can be found here.

Original Thread

By anonymous    2017-12-18

I was following the video for JobScheduler:

But lint was giving me that context.getSystemService(class) is api 23. So am I missing something or did android change something with there api?

Note: Mostly wondering if JobScheduler was introduced in api 21 how would it work without getSystemService(Class)


Original Thread

Submit Your Video

If you have some great dev videos to share, please fill out this form.