Created
December 31, 2018 15:44
-
-
Save bholota/33ecd95c5ab3e5f43b34c4aa29f1d775 to your computer and use it in GitHub Desktop.
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 SampleService : Service() { | |
companion object { | |
private val LAUNCHER = ForegroundServiceLauncher(SampleService::class.java) | |
@JvmStatic | |
fun start(context: Context) = LAUNCHER.startService(context) | |
@JvmStatic | |
fun stop(context: Context) = LAUNCHER.stopService(context) | |
} | |
override fun onCreate() { | |
super.onCreate() | |
startForeground(ID, notification) | |
//... | |
LAUNCHER.onServiceCreated(this) | |
} | |
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | |
//... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment