Last active
May 3, 2019 13:57
-
-
Save fardavide/b761ac2946e6706163c6127fbe69497f to your computer and use it in GitHub Desktop.
This file contains 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
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