Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Last active December 14, 2019 07:07
Show Gist options
  • Select an option

  • Save PatilShreyas/ecac4c19a25348f2d8a5c234e82be550 to your computer and use it in GitHub Desktop.

Select an option

Save PatilShreyas/ecac4c19a25348f2d8a5c234e82be550 to your computer and use it in GitHub Desktop.
class ScheduledWorker(appContext: Context, workerParams: WorkerParameters) :
Worker(appContext, workerParams) {
override fun doWork(): Result {
Log.d(TAG, "Work START")
// Get Notification Data
val title = inputData.getString(NOTIFICATION_TITLE)
val message = inputData.getString(NOTIFICATION_MESSAGE)
// Show Notification
NotificationUtil(applicationContext).showNotification(title!!, message!!)
// TODO Do your other Background Processing
Log.d(TAG, "Work DONE")
// Return result
return Result.success()
}
companion object {
private const val TAG = "ScheduledWorker"
const val NOTIFICATION_TITLE = "notification_title"
const val NOTIFICATION_MESSAGE = "notification_message"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment