Guest User

Untitled

a guest
Nov 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.95 KB | None | 0 0
  1. package com.fursa.spacex.data.background
  2.  
  3. import android.content.Context
  4. import android.os.Build
  5. import androidx.annotation.RequiresApi
  6. import androidx.work.Worker
  7. import androidx.work.WorkerParameters
  8. import com.fursa.spacex.R
  9.  
  10. @RequiresApi(Build.VERSION_CODES.O)
  11. class NotificationWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
  12.  
  13.     private val notificationHelper by lazy {
  14.         NotificationHelper(context)
  15.     }
  16.  
  17.     override fun doWork(): Result {
  18.         showNotification(
  19.             applicationContext.getString(R.string.app_name),
  20.             applicationContext.getString(R.string.app_name)
  21.         )
  22.         return Result.success()
  23.     }
  24.  
  25.     private fun showNotification(title: String, content: String) {
  26.         val builder = NotificationHelper.getNotificationBuilder(title, content, applicationContext)
  27.         notificationHelper.notificationManager.notify(0, builder.build())
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment