diff --git a/app/src/main/java/org/linphone/core/CoreService.kt b/app/src/main/java/org/linphone/core/CoreService.kt index e86efab9e..7434655d9 100644 --- a/app/src/main/java/org/linphone/core/CoreService.kt +++ b/app/src/main/java/org/linphone/core/CoreService.kt @@ -46,8 +46,12 @@ class CoreService : CoreService() { coreContext.notificationsManager.startForeground(this, true) } coreContext.checkIfForegroundServiceNotificationCanBeRemovedAfterDelay(5000) + } else { + ensureCoreExists(applicationContext, pushReceived = false, service = this, useAutoStartDescription = false) } + coreContext.notificationsManager.serviceCreated(this) + return super.onStartCommand(intent, flags, startId) } @@ -73,7 +77,7 @@ class CoreService : CoreService() { Log.i("[Service] Task removed, stopping Core") coreContext.stop() } else { - Log.w("[Service] Task removed but Core in not in background, skipping") + Log.w("[Service] Task removed but Core is not in background, skipping") } } else { Log.i("[Service] Task removed but we were asked to keep the service alive, so doing nothing") diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 5c7f722bb..175a345cb 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -411,7 +411,13 @@ class NotificationsManager(private val context: Context) { } } + fun serviceCreated(createdService: CoreService) { + Log.i("[Notifications Manager] Service has been created, keeping it around") + service = createdService + } + fun serviceDestroyed() { + Log.i("[Notifications Manager] Service has been destroyed") stopForegroundNotification() service = null }