Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created November 23, 2022 04:17
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 Arunshaik2001/34d827425f6bbdbc03ebc002030c1411 to your computer and use it in GitHub Desktop.
Save Arunshaik2001/34d827425f6bbdbc03ebc002030c1411 to your computer and use it in GitHub Desktop.
fun createCustomNotification(context: Context){
val notificationLayout = RemoteViews(context.packageName, R.layout.notification_small)
val notificationLayoutExpanded = RemoteViews(context.packageName, R.layout.notification_small)
val customNotification = NotificationCompat.Builder(context, NotificationChannels.CHANNEL1)
.setSmallIcon(R.drawable.notification_icon)
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setCustomBigContentView(notificationLayoutExpanded)
.build()
with(NotificationManagerCompat.from(context)) {
notify(1445457, customNotification)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment