2

I have a query regarding which API to use for running background jobs for devices which are below 5.1(LOLLIPOP). As JobScheduler API supports only 5.1 and above devices. I wanted to implement a background job API for devices below 5.1. Any one who worked on this can give your valuable suggestions so that I can move according based on the answers.

Thank you.

Vamshi Krishna
  • 87
  • 2
  • 10
  • Have you looked at Service in Android? It is meant to do long running task in background but make sure that you spawn a separate thread for it as Service runs in main thread, otherwise use IntentService which is standard implementation of Service which has its own thread to schedule work to be done. – thefrugaldev Mar 23 '17 at 11:08
  • @mobiledev I have services and intent services to do that long running operations but it is about firing the jobs i'm interested in. Have you worked on any of these which I was mentioning in the question. – Vamshi Krishna Mar 24 '17 at 05:39
  • You may have to use AlarmManager along with IntentService in order to achieve it. I guess, you basically want to fire a job when certain condition is met for which you can use AlarmManager and IntentService. – thefrugaldev Mar 24 '17 at 06:58
  • @mobiledev I have implemented JobScheduler API for devices which are 5.1 and above. But for devices below 5.1 i'm looking for a library which does that rather writing my boilerplate code. – Vamshi Krishna Mar 24 '17 at 07:51

1 Answers1

1

Simply use android-job. It did all the work for you of implementing all APIs.

A utility library for Android to run jobs delayed in the background. Depending on the Android version either the JobScheduler, GcmNetworkManager or AlarmManager is getting used.

vRallev
  • 4,982
  • 3
  • 31
  • 34