I'm developing and alarm like app that send notifications with fullscreenintents
The notifications themselves should be silent because the alarm sound will be looped and played apart from the notification sound.
But whatever I do, I can't change the sound or the vibration of the app
val fullScreenPendingIntent = PendingIntent.getActivity(context, 0,
Intent(context, SecondActivity::class.java), FLAG_IMMUTABLE)
val closeButtonPendingIntent = PendingIntent.getBroadcast(context, 0, Intent(context, CloseButton::class.java), FLAG_IMMUTABLE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val name = "name"
val descriptionText = "desc"
val importance = NotificationManager.IMPORTANCE_HIGH
val channel = NotificationChannel("abc", name, importance).apply {
description = descriptionText
}
val notificationManager: NotificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
channel.setSound(null, null)
val builder = NotificationCompat.Builder(context, "abc")
.setSmallIcon(R.drawable.ic_android_black_24dp)
.setContentTitle("textTitle")
.setContentText("textContent")
.setVibrate(longArrayOf(1L, 2L, 3L))
.setSound(null)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.setFullScreenIntent(fullScreenPendingIntent, true)
.addAction(1, "a", closeButtonPendingIntent)
.setOnlyAlertOnce(false)
.setOngoing(true)
with(NotificationManagerCompat.from(context)) {
notify(1, builder.build()).also { playNotification(context) }
}