Skip to content

Instantly share code, notes, and snippets.

@heronsanches
heronsanches / foregroundService
Last active October 16, 2020 14:10
Foreground Service: starting and biding
/** You should start the service by calling
* [startForegroundService] for API >= [Build.VERSION_CODES.O] to be certain that the Android will
* not try to kill your service so soon. */
class SomeService : Service() {
private val serviceBinder = PrepareBackupBinder()
override fun onCreate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createSomeNotificationChannel()