Home > Back-end >  JobScheduler not having schedule options in Android Kotlin
JobScheduler not having schedule options in Android Kotlin

Time:09-15

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)

I am getting error when using the schedule method of JobScheduler

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.

  • Related