Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyAppService: Service() {
- private var serviceLooper: Looper? = null
- private var serviceHandler: ServiceHandler? = null
- override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
- HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND).apply {
- start()
- // Get the HandlerThread's Looper and use it for our Handler
- serviceLooper = looper
- serviceHandler = ServiceHandler(looper)
- Thread() {
- runBlocking { // this: CoroutineScope
- launch {
- globalEventIncomePush.collect { model ->
- createNotificationChannel(model.channelId,model.channelId, this@MyAppService)
- simpleNotification(this@MyAppService, model.channelId, model.notificationId, model.textTitle, model.textContext)
- }
- }
- }
- }.start()
- }
- return super.onStartCommand(intent, flags, startId)
- }
- override fun onBind(p0: Intent?): IBinder? {
- return null
- }
- private inner class ServiceHandler(looper: Looper) : Handler(looper) {
- override fun handleMessage(msg: Message) {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement