Skip to content

Instantly share code, notes, and snippets.

@mohosyny
Created May 13, 2020 18:28
Show Gist options
  • Save mohosyny/3f924cde8eb9818c1ee89f2fe5941259 to your computer and use it in GitHub Desktop.
Save mohosyny/3f924cde8eb9818c1ee89f2fe5941259 to your computer and use it in GitHub Desktop.
lateinit var notification: NotificationCompat.Builder
lateinit var manager: NotificationManager
val channel = "NotificationTest"
lateinit var notificationChannel: NotificationChannel
manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationChannel = NotificationChannel(channel, "notification", NotificationManager.IMPORTANCE_DEFAULT)
manager.createNotificationChannel(notificationChannel)
}
notification=NotificationCompat.Builder(this,channel)
.setContentTitle("mohosyny")
.setContentText("this is for test")
.setAutoCancel(true)
.setSmallIcon(R.mipmap.ic_launcher)
manager.notify(1,notification.build())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment