From 8cd10945267793caec00a2d6be3f5c56506d52d2 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 6 Feb 2023 08:10:05 +0530 Subject: [PATCH] Use ServiceCompat. --- .../java/com/github/libretube/services/DownloadService.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 8f04bf6a6..f530da78a 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -5,9 +5,9 @@ import android.app.PendingIntent import android.app.Service import android.content.Intent import android.os.Binder -import android.os.Build import android.os.IBinder import androidx.core.app.NotificationCompat +import androidx.core.app.ServiceCompat import com.github.libretube.R import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance @@ -315,9 +315,7 @@ class DownloadService : Service() { // Stop the service if no downloads are active. if (downloadQueue.none { it.value }) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - stopForeground(STOP_FOREGROUND_DETACH) - } + ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_DETACH) sendBroadcast(Intent(ACTION_SERVICE_STOPPED)) stopSelf() }