From 2ca4d96f0cd2d1a843f3413112dc3b23a0c7d69f Mon Sep 17 00:00:00 2001 From: Dave Craig Date: Tue, 31 Dec 2024 10:44:48 +0000 Subject: [PATCH] Keep service alive when app is closed #305 This trivial change stops the service from shutting down when the app is closed. That behaviour came in when we added MediaSessionService and by ignoring the onTaskRemoved call we can revert to the previous behaviour. --- .../scottishtecharmy/soundscape/services/SoundscapeService.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/org/scottishtecharmy/soundscape/services/SoundscapeService.kt b/app/src/main/java/org/scottishtecharmy/soundscape/services/SoundscapeService.kt index 6c23fc14..5d66b497 100644 --- a/app/src/main/java/org/scottishtecharmy/soundscape/services/SoundscapeService.kt +++ b/app/src/main/java/org/scottishtecharmy/soundscape/services/SoundscapeService.kt @@ -178,6 +178,9 @@ class SoundscapeService : MediaSessionService() { } } + override fun onTaskRemoved(rootIntent: Intent?) { + Log.d(TAG, "onTaskRemoved for service - ignoring, as we want to keep running") + } override fun onDestroy() { // If _mediaSession is not null, run the following block mediaSession?.run {