Skip to content

Instantly share code, notes, and snippets.

@jfsurban
Created June 28, 2013 01:49
Show Gist options
  • Save jfsurban/5881883 to your computer and use it in GitHub Desktop.
Save jfsurban/5881883 to your computer and use it in GitHub Desktop.
Check if a Service is running in Android - http://stackoverflow.com/a/5921190/718
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (MyService.class.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