A unified job library for Android

SDK

A unified job library for Android

Posted by Ralf Wondratschek on 26 Oct 2015

Posted by Ralf Wondratschek on 26 Oct 2015

Android provides three different APIs to run tasks in the future. All of them have their benefits and downsides. The AlarmManager’s API has changed over time, so you need to be careful which method you use on which platform. The JobScheduler is only available on Android Lollipop and Marshmallow, whereas the GcmNetworkManager is only available on devices with Google Play preinstalled.

There are three options with changing API levels, so it can be hard to know which one you need. You will also end up with many different paths in your code all doing the same for a different environment. Today, we’re open-sourcing a unified library to schedule jobs on Android. Depending on your requirements, this library decides which API suits your job. It provides a superset of all features from the existing AlarmManager, JobScheduler and GcmNetworkManager, e.g. you can run your job only if the device has a working Internet connection and is charging.

Setting up the library is straightforward. You only need to initialize the JobManager and then you can start scheduling your jobs. You don’t need to declare any services, receivers or permissions in your manifest. The project page on GitHub has you covered with detailed instructions and code samples.

We’re excited to get your feedback, feature recommendations, bug reports and pull requests. Happy coding!

View more stories in 'SDK'

7 Comments RSS

  • Mensajeria bogota

    Therefore Adroid is my favorite operating system , open source is constantly updated , and not by others that this APIs, this great.

  • Hossein Reyhani

    I have an important question: Does this support back-off criteria for a periodic job?
    I found this in java-doc: Note that it’s not allowed to change the back-off criteria for a periodic job.
    If so then what is default back-off criteria for a periodic job anyway?
    Thanks a lot!

    • Ralf Wondratschek

      Periodic jobs don’t have a back-off criteria. If the job fails, then it will simply run in the next interval again.