From b8ee4152a3f1c15ca10613501d484a7921fb7fc6 Mon Sep 17 00:00:00 2001 From: andrekir Date: Tue, 3 Jan 2023 21:02:31 -0300 Subject: [PATCH] use ServiceCompat.stopForeground() for API < 24 compatibility --- .../main/java/com/geeksville/mesh/service/MeshService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 7be997ca8..38e55eeb6 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.os.IBinder import android.os.RemoteException +import androidx.core.app.ServiceCompat import androidx.core.content.edit import com.geeksville.mesh.analytics.DataPair import com.geeksville.mesh.android.GeeksvilleApplication @@ -263,7 +264,7 @@ class MeshService : Service(), Logging { startForeground(serviceNotifications.notifyId, notification) return if (!wantForeground) { - stopForeground(STOP_FOREGROUND_REMOVE) + ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE) START_NOT_STICKY } else { START_STICKY @@ -275,7 +276,8 @@ class MeshService : Service(), Logging { saveSettings() - stopForeground(STOP_FOREGROUND_REMOVE) // Make sure we aren't using the notification first + // Make sure we aren't using the notification first + ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE) serviceNotifications.close() super.onDestroy()