Skip to content

Instantly share code, notes, and snippets.

@molidev8
Created June 11, 2022 17:02
Show Gist options
  • Save molidev8/67be098e3f763a95a2f48a83a9d9c74f to your computer and use it in GitHub Desktop.
Save molidev8/67be098e3f763a95a2f48a83a9d9c74f to your computer and use it in GitHub Desktop.
A ServiceConnection implementation
private lateinit var timerService: TimerService
private var isTimerServiceBound: Boolean = false
private val timerServiceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName?, binder: IBinder?) {
timerService = (binder as TimerService.TimerBinder).service
isTimerServiceBound = true
}
override fun onServiceDisconnected(p0: ComponentName?) {
isTimerServiceBound = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment