Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active February 22, 2022 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skydoves/2b5aebe5c42473bfccf6069258583049 to your computer and use it in GitHub Desktop.
Save skydoves/2b5aebe5c42473bfccf6069258583049 to your computer and use it in GitHub Desktop.
myservice_example
class MyService : Service() {
private var binder: IBinder? = null
override fun onCreate() {
// The service is being created
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
return super.onStartCommand(
intent,
flags,
startId
) // indicates how to behave if the service is killed
}
override fun onBind(intent: Intent?): IBinder? {
// A client is binding to the service with bindService()
return binder
}
override fun onDestroy() {
// The service is no longer used and is being destroyed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment