I need to make callbacks from Service to catch them in my ViewModel, operate on data and convert to LiveData. I'm trying to make callbacks like this:
class MyService : Service() {
interface Callbacks {
fun onForegroundStatusChanged(isForeground: Boolean)
fun onLocationChanged(location: Location)
}
private var callbacks: Callbacks? = null
override fun onCreate() {
super.onCreate()
callbacks = this@LocationService as Callbacks?
}
But IDE telling me that this as
cast will never succeed. Can you help me with this callbacks?