isServiceRunning

Checks whether a service of type T, owned by the calling app, is currently running.

This hides the ActivityManager lookup and class-name comparison behind a reified service type.

Relies on ActivityManager.getRunningServices, which reliably returns services owned by the calling app, even on Android O (API 26) and above.

Note: This does not detect services from other apps and should not be used to determine system-wide service state.

Throws

when trying to query a service's state that is not owned by the calling app.