mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2024-12-16 10:19:38 +01:00
Use ContextCompat.startForegroundService in startTimerService
The compat one has the logic method has, let's use that instead.
This commit is contained in:
parent
b47b3854ed
commit
62cb24f5d6
@ -9,8 +9,8 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.extensions.getFormattedDuration
|
import com.simplemobiletools.clock.extensions.getFormattedDuration
|
||||||
import com.simplemobiletools.clock.extensions.getOpenTimerTabIntent
|
import com.simplemobiletools.clock.extensions.getOpenTimerTabIntent
|
||||||
@ -118,13 +118,8 @@ class TimerService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun startTimerService(context: Context) {
|
fun startTimerService(context: Context) {
|
||||||
if (isOreoPlus()) {
|
ContextCompat.startForegroundService(context, Intent(context, TimerService::class.java))
|
||||||
context.startForegroundService(Intent(context, TimerService::class.java))
|
|
||||||
} else {
|
|
||||||
context.startService(Intent(context, TimerService::class.java))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object TimerStopService
|
object TimerStopService
|
||||||
|
Loading…
Reference in New Issue
Block a user