I am trying to use JobSchedule in Android Kotlin but not getting the schedule method in JobScheduler.
Here is my code
val jobScheduler = applicationContext
.getSystemService(JOB_SCHEDULER_SERVICE) as JobScheduler
val componentName = ComponentName(this, JobScheduler::class.java)
val jobInfo = JobInfo.Builder(12, componentName)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.build()
jobScheduler.schedule(jobInfo)
CodePudding user response:
May be you are doing this in some other piece of code. Please check where you are doing this. Try it in new activity and if still the problem persist then let me know.