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?
.setService(MyJobService::class)
or.setService(MyJobService::class.java!!)
(to be compliant with Class!) I guess. – MajorShepardfirebase-jobdispatcher:0.8.5'
? I'm seeingImprove Kotlin support (#193)
in their repository. Your code seems to be correct based on what I've read. – MajorShepard