From 56c76249eba333fa4941a2c51ef20f44a88ffccf Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 11 Jan 2023 07:37:13 +0530 Subject: [PATCH] Use ServiceCompat. --- .../java/com/github/libretube/services/BackgroundMode.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 636b940c9..523aad31a 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -10,6 +10,7 @@ import android.os.Handler import android.os.IBinder import android.os.Looper import android.widget.Toast +import androidx.core.app.ServiceCompat import com.fasterxml.jackson.databind.ObjectMapper import com.github.libretube.R import com.github.libretube.api.RetrofitInstance @@ -373,12 +374,7 @@ class BackgroundMode : Service() { // called when the user pressed stop in the notification // stop the service from being in the foreground and remove the notification - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - stopForeground(STOP_FOREGROUND_REMOVE) - } else { - @Suppress("DEPRECATION") - stopForeground(true) - } + ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE) // destroy the service stopSelf()