Skip to content

Instantly share code, notes, and snippets.

@molidev8
Last active June 13, 2022 17:22
Show Gist options
  • Save molidev8/57b11ae6b0a58b8558af1705819be788 to your computer and use it in GitHub Desktop.
Save molidev8/57b11ae6b0a58b8558af1705819be788 to your computer and use it in GitHub Desktop.
A function to show an Android notification
fun createNotification(
context: Context,
title: String,
content: String,
) {
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
val notification = builder.setContentTitle(title).setContentText(content)
.setSmallIcon(R.drawable.ic_launcher_foreground).build()
NotificationManagerCompat.from(context).notify(id, notification)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment