Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check if service is running
private boolean isMyServiceRunning(Class<?> serviceClass) {
logger.debug("serviceClass={}", serviceClass);
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment