Search code examples
androidandroid-5.0-lollipop

Android 5.0 JobScheduler API on earlier versions?


I'm building an Android application, which makes use of a manifest broadcast receiver to know when the device is plugged in. I think Android 5.0 JobScheduler API would be a much better way of doing this, but I have one question: is it possible to use this API or a similar one on earlier versions of Android? If it is not possible, what would be the best option to do this (instead of a manifest broadcast receiver)?


Solution

  • Important Update

    For Now onward everybody should use WorkManager for deferrable background tasks.

    • This library is backward compatible
    • It use JobScheduler,FirebaseJobDispatcher or AlarmManager
    • No Need to depend on play service library.
    • Recommended by Google for deferrable background work.
    • Can use features like chaining, constraints etc.

    https://developer.android.com/guide/background/#workmanager https://developer.android.com/topic/libraries/architecture/workmanager/