I try to setup JobService using FirebaseJobDispatcher.
Here is my JobService:
class MyJobService : JobService() {
override fun onStartJob(job: JobParameters): Boolean {
    // Do some work here
   return false //return false if job done otherwise return true
}
override fun onStopJob(job: JobParameters): Boolean {
    return false //Should this job be retried?"
   }
}
However when i try to setup it like this:
val dispatcher = FirebaseJobDispatcher(GooglePlayDriver(this))
val myJob = dispatcher.newJobBuilder()
    .setService(MyJobService::class.java) // the JobService that will be called
    .setTag("my-unique-tag")        // uniquely identifies the job
    .build()
I am getting this compiler error in Android Studio:
Type inference failed. Expected type mismatch: inferred type is Class but Class! was expected
How to setup it in Kotlin correctly?
It seems that I imported wrong JobService.
Instead of:
import android.app.job.JobParameters
import android.app.job.JobService
Should be:
import com.firebase.jobdispatcher.JobParameters
import com.firebase.jobdispatcher.JobService
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With