I have a service which I believe to have running in the foreground, How do I check if my implementation is working?
Little touch on Adam's answer:
@Suppress("DEPRECATION") // Deprecated for third party Services.
fun Context.isServiceForegrounded(service: Class) =
(getSystemService(ACTIVITY_SERVICE) as? ActivityManager)
?.getRunningServices(Integer.MAX_VALUE)
?.find { it.service.className == service.name }
?.foreground == true