Reputation: 1920
In my application i successfully create a notification but the sound that plays is the default which i dont want. I have a sound clip in the resources/raw/basic_notification.mp3 and i want to play this when the notification is built.
fun createContactMessageNotification(intent: PendingIntent?, title: String?, content: String): Notification {
return NotificationCompat.Builder(Application.instance, NautilusParams.NOTIFICATION_CHANNEL).apply {
setSmallIcon(R.drawable.ic_person_white_24dp)
setContentIntent(intent)
setContentTitle(title)
setContentText(content)
setAutoCancel(true)
setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+ =Application.instance.packageName + "/"+ R.raw.basic_notification))
setVibrate(longArrayOf(0, 150, 200, 150, 200, 150))
priority = NotificationCompat.PRIORITY_MAX
setCategory(NotificationCompat.CATEGORY_MESSAGE)
}.build()
}
and i call it like
val notification = NotificationBuilder.createContactMessageNotification(resultPendingIntent,
message.fromaccountfirstname,
MessageUtils.getNotificationBodyByNewMessageType(message))
NotificationManagerCompat.from(Application.instance).notify(message.fromaccountid, notification)
However this doesnt work. I also tried to add it in the Notification Channel builder with the AudioAttributes but still. I only got the default on. How can i overcome this..?
Upvotes: 3
Views: 143