So I\'m not sure where/how to implement this method to make my service run in the foreground. Currently I start my service by the following in another activity:
<
In addition to RAWA answer, this peace of code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent)
} else {
startService(intent)
}
You can change to:
ContextCompat.startForegroundService(context, yourIntent);
If you will look inside this method then you can see that this method do all checking work for you.