The correct way to determine if service is running
I am running foreground services in my app and I need to deremine if they running in my activity.
From my searches I found that this is the option:
private fun isMyServiceRunning(serviceClass: Class): Boolean {
val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (service in manager.getRunningServices(Int.MAX_VALUE)) {
if (serviceClass.name == service.service.className) {
return true
}
}
return false
}
but:...