From ac452813aaa5c1ffd76a449ad5e75dd9533b61c8 Mon Sep 17 00:00:00 2001 From: Mygod Date: Mon, 11 Jul 2022 17:10:27 -0400 Subject: [PATCH] Migrate stopForeground --- .../src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt b/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt index 740b170e..c2b6403e 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt @@ -64,7 +64,9 @@ object ServiceNotification { fun stopForeground(service: Service) = synchronized(this) { deviceCountsMap.remove(service) ?: return@synchronized val shutdown = deviceCountsMap.isEmpty() - service.stopForeground(shutdown) + if (Build.VERSION.SDK_INT >= 33) { + service.stopForeground(if (shutdown) Service.STOP_FOREGROUND_REMOVE else Service.STOP_FOREGROUND_DETACH) + } else @Suppress("DEPRECATION") service.stopForeground(shutdown) if (!shutdown) manager.notify(NOTIFICATION_ID, buildNotification(service)) }