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; | |
} |
@MetinSeylan Can you describe more what you meant by ping pong with localbroadcaster or give some sample code for this?
@MetinSeylan Can you describe more what you meant by ping pong with localbroadcaster or give some sample code for this?
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does anyone know if it's possible to see if an activity/service of another app is currently active/in foreground?
Working with android 10 - making a launcher for another (older) app and have to be able to see if it's already running or not (so that I don't start it twice).