Merge pull request #2981 from Isira-Seneviratne/ServiceCompat

Use ServiceCompat in DownloadService.
This commit is contained in:
Bnyro 2023-02-06 15:28:51 +01:00 committed by GitHub
commit 7a597d8ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}