my app is working fine on 29 and above but below 29 i am getting this error , i dont want to use any constraint is their any way resolve this issue without using constraits
private fun scheduleService(sms: Sms) {
Log.i("JobID","${sms.messages.messageId.toInt()}")
val jobScheduler= requireContext().getSystemService(AppCompatActivity.JOB_SCHEDULER_SERVICE) as JobScheduler
val serializedSms = GsonUtils.serializeSms(sms)
val componentName = ComponentName(requireContext() , TodoJobService::class.java)
val jobInfo = JobInfo.Builder(sms.messages.messageId.toInt() ,componentName)
jobInfo.setPersisted(true )
val persistableBundle = PersistableBundle()
persistableBundle.putString(TodoJobService.JOB_KEY,serializedSms)
jobInfo.setExtras(persistableBundle)
jobScheduler.schedule(jobInfo.build())
}
CodePudding user response:
Prior to Android version
Build.VERSION_CODES#Q
, you had to specify at least one constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an exception when building. From Android versionBuild.VERSION_CODES#Q
and onwards, it is valid to schedule jobs with no constraints.
Can't you just set a constraint that doesn't matter? A low minimum, the backoff policy you prefer, something like that