Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
val notificationManager = context.getSystemService<NotificationManager>()!!
val title = context.getString( R.string.cache_cleaned_title )
val id = context.getString( R.id.cache_cleaned_id ).toInt()
val channelId = context.getString( R.string.background_group_id )
val channelName = context.getString( R.string.background_group_name )
val notification = NotificationCompat.Builder( context, channelId )
.setSmallIcon( R.drawable.ic_app )
.setContentTitle( title )
.setPriority( NotificationCompat.PRIORITY_LOW )
.build()
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
val channel = NotficationChannel(
channelId, channelName, NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel( channel )
}
notificationManager.notify( id, notification )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment