Skip to content

Instantly share code, notes, and snippets.

@jaydeepw
Created May 15, 2012 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaydeepw/2699617 to your computer and use it in GitHub Desktop.
Save jaydeepw/2699617 to your computer and use it in GitHub Desktop.
Android: Checking if a Service is already running in the Android system.
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("com.example.MyService".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