Created
June 25, 2012 14:20
-
-
Save kevinmcmahon/2988931 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 isServiceRunning() { | |
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); | |
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){ | |
if("com.example.MyNeatoIntentService".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
Send broadcast "PING", listen in service, if service is working, it will bring back "PONG" so that can indicate that service is running. If nothing is returned (you can set like 5s waiting period), this indicate that service is not running.