Last active
June 13, 2022 17:22
-
-
Save molidev8/57b11ae6b0a58b8558af1705819be788 to your computer and use it in GitHub Desktop.
A function to show an Android notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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