Skip to content
Snippets Groups Projects
Commit 01728559 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Avoid useless try to start the service in background

parent 9fdea53b
No related branches found
No related tags found
Loading
......@@ -14,7 +14,6 @@ import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.resources.*
import org.videolan.tools.*
import java.io.File
import java.util.ArrayList
import kotlin.coroutines.resume
......@@ -92,15 +91,10 @@ suspend fun Context.dbExists(coroutineContextProvider: CoroutineContextProvider
}
fun Context.launchForeground(intent: Intent) {
try {
startService(intent)
} catch (e: IllegalStateException) {
//wait for the UI thread to be ready
val ctx = this
AppScope.launch(Dispatchers.Main) {
intent.putExtra("foreground", true)
ContextCompat.startForegroundService(ctx, intent)
}
val ctx = this
AppScope.launch(Dispatchers.Main) {
intent.putExtra("foreground", true)
ContextCompat.startForegroundService(ctx, intent)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment