Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vicky7230/b6f972cfa9f05a6ec98f4eead944d474 to your computer and use it in GitHub Desktop.
Save vicky7230/b6f972cfa9f05a6ec98f4eead944d474 to your computer and use it in GitHub Desktop.
Check if an intent service is running
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (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