Reputation: 71
Expectation: App need to play the sound for the notification when the scheduled DND is enabled for specific time interval and even the DND Exception Media Sound was disabled by the user.
Our App has the DND Permission access to play the sound and show notification even when the scheduled DND is On.
When the DND setting is enable, also in the exception category Media Sound is disabled by the user. We couldn’t able to play the Notification sound programmatically.
We tried programmatically to save the current DND mode and then turn off the DND mode by the NotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL) it will disable the DND and played the sound for Notification by setting the volume for the media. After user set interval time, here if we turn on the DND mode with previously saved DND mode programmatically. The Android OS update the DND mode control to our App.In this Scenario, DND mode schedule interval time is not executed.
Sample Code for Notification Builder:
val notificationBuilder: NotificationCompat.Builder =
NotificationCompat.Builder(context, channelId).apply {
setSmallIcon(smallIcon)
setContentTitle(title)
setContentText(message)
setStyle(NotificationCompat.BigTextStyle().bigText(message))
priority = NotificationCompat.PRIORITY_HIGH
setCategory(NotificationCompat.CATEGORY_ALARM)
setContentIntent(contentIntent)
setChannelId(channelId)
setVibrate(NotificationUtils.vibrationPattern)
setDeleteIntent(deletePendingIntent)
setAutoCancel(true)
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
}
Upvotes: 0
Views: 39