From 40b95edf7120a684a5d4d0b089cbaaed1425071c Mon Sep 17 00:00:00 2001 From: Mrslimek Date: Fri, 23 Oct 2026 23:03:48 +0400 Subject: [PATCH] fix(service): stop orphaned "processing action" notification MusicService posts a temporary foreground notification (ID 101) whenever the service is created or receives an external command. While playback is active the notification is intentionally left in place, assuming Media3 will replace it. Media3 does not always call startForeground(): when no foreground start is required it posts its notification with notify() and detaches the service via stopForeground(false). With a different notification ID the temporary notification was neither replaced nor removed, leaving an ongoing, non-dismissible "Processing playback action..." notification next to the working media notification. Use MusicService.NOTIFICATION_ID for the media notification as well, so every media update replaces the temporary notification and MediaNotificationManager.removeNotification() clears it. --- .../data/service/LocalOnlyMediaNotificationProvider.kt | 4 +++- .../com/theveloper/pixelplay/data/service/MusicService.kt | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/theveloper/pixelplay/data/service/LocalOnlyMediaNotificationProvider.kt b/app/src/main/java/com/theveloper/pixelplay/data/service/LocalOnlyMediaNotificationProvider.kt index f227bcd245..89b1eac9fe 100644 --- a/app/src/main/java/com/theveloper/pixelplay/data/service/LocalOnlyMediaNotificationProvider.kt +++ b/app/src/main/java/com/theveloper/pixelplay/data/service/LocalOnlyMediaNotificationProvider.kt @@ -44,7 +44,9 @@ class LocalOnlyMediaNotificationProvider( }.getOrElse { notification.notification } - return MediaNotification(notification.notificationId, localOnlyNotification) + // Same ID as MusicService's temporary foreground notification, so media updates + // replace it instead of leaving it behind as an orphaned notification. + return MediaNotification(MusicService.NOTIFICATION_ID, localOnlyNotification) } override fun handleCustomCommand( diff --git a/app/src/main/java/com/theveloper/pixelplay/data/service/MusicService.kt b/app/src/main/java/com/theveloper/pixelplay/data/service/MusicService.kt index adab461ca8..994863b2a1 100644 --- a/app/src/main/java/com/theveloper/pixelplay/data/service/MusicService.kt +++ b/app/src/main/java/com/theveloper/pixelplay/data/service/MusicService.kt @@ -257,6 +257,8 @@ class MusicService : MediaLibraryService() { companion object { private const val TAG = "MusicService_PixelPlay" + + /** Also used by [LocalOnlyMediaNotificationProvider]; the IDs must stay in sync. */ const val NOTIFICATION_ID = 101 const val ACTION_SLEEP_TIMER_EXPIRED = "com.theveloper.pixelplay.ACTION_SLEEP_TIMER_EXPIRED" const val EXTRA_FORCE_FOREGROUND_ON_START =