From 4a5f6cf1fef6b98b6a5152d867162fce1f2c79ae Mon Sep 17 00:00:00 2001 From: Dariusz Olszewski Date: Sat, 27 Nov 2021 20:42:57 +0100 Subject: [PATCH] Do not play notification sounds on Oreo or later On devices with Android 8.0 (Oreo) or later, notification sound will be handled by the system, if notifications have not been disabled by the user. Signed-off-by: Dariusz Olszewski --- .../java/com/nextcloud/talk/jobs/NotificationWorker.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 9f2a2e09e..13e1f3ef6 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -491,6 +491,11 @@ public class NotificationWorker extends Worker { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(notificationId, notification); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + // On devices with Android 8.0 (Oreo) or later, notification sound will be handled by the system + // if notifications have not been disabled by the user. + return; + } if (!notification.category.equals(Notification.CATEGORY_CALL) || !muteCall) { String ringtonePreferencesString;