0

My minSdk is 19 and my targetSdk is 27 I am trying to use JobScheduler for BOOT_COMPLETED for Build.Version >= 21 devices and traditional method for pre-lollipop devices. But I am getting calls require 21 current minSdk is 19.

enter image description here

What annotations do I need to use, I tried TargetApi(21) but it ONLY targets lollipop and not higher.

DeiDei
  • 10,205
  • 6
  • 55
  • 80

2 Answers2

1

You can try Evernote's Android-Job. It provides similar functionality for lower API levels.

Or WorkManager just came out. I believe it is currently in beta. It's library is similar to Evernote's and will also use either AlarmManager or Firebase JobDispatcher for API levels <21.
https://developer.android.com/reference/androidx/work/WorkManager

Steve Miskovetz
  • 2,360
  • 13
  • 29
0

Jobscheduler was introduced in 5.0. For versions lower than 5.0, use Firebase JobDispatcher. Refer this documentation for more details.

Firebase JobDispatcher is an open-source library that provides an API similar to JobScheduler in the Android platform. Firebase JobDispatcher serves as a JobScheduler-compatibility layer for apps targeting versions of Android lower than 5.0 (API level 21).

Sagar
  • 23,903
  • 4
  • 62
  • 62