From a0d0bb0d48381abc030e19f434d8b0c686799c6d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Feb 2022 14:41:39 +0100 Subject: [PATCH] Prevent runtime exception if we failed to build service notification --- .../java/org/linphone/notifications/NotificationsManager.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 7be2c78b2..4df57605a 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -327,6 +327,10 @@ class NotificationsManager(private val context: Context) { fun startForeground(coreService: CoreService, useAutoStartDescription: Boolean = true) { if (serviceNotification == null) { createServiceNotification(useAutoStartDescription) + if (serviceNotification == null) { + Log.e("[Notifications Manager] Failed to create service notification, aborting foreground service!") + return + } } currentForegroundServiceNotificationId = SERVICE_NOTIF_ID Log.i("[Notifications Manager] Starting service as foreground [$currentForegroundServiceNotificationId]")