Skip to content
Snippets Groups Projects
Verified Commit 3acf0902 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fix potential crashes when creating foreground service

parent 00410a83
No related branches found
No related tags found
No related merge requests found
Pipeline #364 canceled
......@@ -23,6 +23,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.Build
import android.os.IBinder
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
......@@ -66,8 +67,12 @@ class BackendServiceConnection : ServiceConnection, DefaultLifecycleObserver {
}
fun start(intent: Intent = QuasselService.intent(context!!)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context?.startForegroundService(intent)
} else {
context?.startService(intent)
}
}
@Synchronized
fun bind(intent: Intent = QuasselService.intent(context!!), flags: Int = 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment