From 62cb24f5d699e4991c26132bb4bb61c871629e7e Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sat, 4 Dec 2021 21:29:04 +0330 Subject: [PATCH] Use ContextCompat.startForegroundService in startTimerService The compat one has the logic method has, let's use that instead. --- .../com/simplemobiletools/clock/services/TimerService.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/services/TimerService.kt b/app/src/main/kotlin/com/simplemobiletools/clock/services/TimerService.kt index efce8159..f1716056 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/services/TimerService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/services/TimerService.kt @@ -9,8 +9,8 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.IBinder -import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat import com.simplemobiletools.clock.R import com.simplemobiletools.clock.extensions.getFormattedDuration import com.simplemobiletools.clock.extensions.getOpenTimerTabIntent @@ -118,13 +118,8 @@ class TimerService : Service() { } } -@RequiresApi(Build.VERSION_CODES.O) fun startTimerService(context: Context) { - if (isOreoPlus()) { - context.startForegroundService(Intent(context, TimerService::class.java)) - } else { - context.startService(Intent(context, TimerService::class.java)) - } + ContextCompat.startForegroundService(context, Intent(context, TimerService::class.java)) } object TimerStopService