Skip to content

Instantly share code, notes, and snippets.

@GitEliteNovice
Last active August 28, 2019 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitEliteNovice/fdaa79c9bb91070d97a4a16b324fb5ee to your computer and use it in GitHub Desktop.
Save GitEliteNovice/fdaa79c9bb91070d97a4a16b324fb5ee to your computer and use it in GitHub Desktop.
val pendingIntent: PendingIntent =
Intent(this, ExampleActivity::class.java).let { notificationIntent ->
PendingIntent.getActivity(this, 0, notificationIntent, 0)
}
val notification: Notification = Notification.Builder(this, CHANNEL_DEFAULT_IMPORTANCE)
.setContentTitle(getText(R.string.notification_title))
.setContentText(getText(R.string.notification_message))
.setSmallIcon(R.drawable.icon)
.setContentIntent(pendingIntent)
.setTicker(getText(R.string.ticker_text))
.build()
startForeground(ONGOING_NOTIFICATION_ID, notification)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment