Created
June 11, 2022 17:07
-
-
Save molidev8/6e5bbc077f8394316b444c97fb374118 to your computer and use it in GitHub Desktop.
A foreground service intialization
This file contains hidden or 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
startService(Intent(this, TimerService::class.java)) | |
bindService( | |
Intent(this, TimerService::class.java), | |
timerServiceConnection, | |
Context.BIND_AUTO_CREATE | |
) | |
setContent { | |
// Some Jetpack Compose UI | |
} | |
} | |
override fun onDestroy() { | |
super.onDestroy() | |
if (isTimerServiceBound) { | |
unbindService(timerServiceConnection) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment