fix background service for lower Android versions

This commit is contained in:
Nephys222 2022-08-21 14:10:57 +05:00
parent f99ef78699
commit 9aee6bc964

View File

@ -2,6 +2,7 @@ package com.github.libretube.util
import android.content.Context
import android.content.Intent
import android.os.Build
import com.github.libretube.services.BackgroundMode
/**
@ -21,6 +22,10 @@ object BackgroundHelper {
if (position != null) intent.putExtra("position", position)
// start the background mode as foreground service
context.startForegroundService(intent)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
context.startForegroundService(intent)
} else {
context.startService(intent)
}
}
}