Skip to content

Instantly share code, notes, and snippets.

@victorbrndls
Last active June 8, 2021 23:59
Show Gist options
  • Save victorbrndls/686fa3509c794b31871826e1f06cb756 to your computer and use it in GitHub Desktop.
Save victorbrndls/686fa3509c794b31871826e1f06cb756 to your computer and use it in GitHub Desktop.
private fun createNotification(): Notification {
val contentIntent = Intent(context, HomeActivity::class.java)
val contentPendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0)
return NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.notifications_active_black_24)
.setColor(ResourcesCompat.getColor(context.resources, R.color.purple_200, null))
.setContentTitle(context.getString(R.string.notification_title))
.setAutoCancel(true)
.setContentIntent(contentPendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment