-
-
Save skydoves/2b5aebe5c42473bfccf6069258583049 to your computer and use it in GitHub Desktop.
myservice_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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