Created
May 15, 2012 06:43
-
-
Save jaydeepw/2699617 to your computer and use it in GitHub Desktop.
Android: Checking if a Service is already running in the Android system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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