Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinmcmahon/2988931 to your computer and use it in GitHub Desktop.
Save kevinmcmahon/2988931 to your computer and use it in GitHub Desktop.
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;
}
@Paget96
Copy link

Paget96 commented Apr 15, 2025

@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