I'm developing an alarm app which is displaying a notification to the user in a certain time with a long notification sound.
The problem is notification doesn’t stop if I’m connecting bluetooth headphone to the phone, even if I dismissed the notification and even if I killed the app.
val builder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setDefaults(Notification.FLAG_ONGOING_EVENT)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.setContentTitle(alarm.getNotificationTitle(context))
.setContentText(alarm.getNotificationDescription(context))
.setPriority(NotificationCompat.PRIORITY_MAX)
.setFullScreenIntent(pendingIntent, true)
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)