Posted By

rockschtar on 11/23/11


Tagged

service android


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

rockschtar
mmcachran


Android check if service running


 / Published in: Java
 

This functions checks if a service is running or not.

  1. private Boolean isServiceRunning(String serviceName) {
  2.  
  3. ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  4. for (RunningServiceInfo runningServiceInfo : activityManager.getRunningServices(Integer.MAX_VALUE)) {
  5. if (serviceName.equals(runningServiceInfo.service.getClassName())) {
  6. return true;
  7. }
  8. }
  9. return false;
  10. }

Report this snippet  

You need to login to post a comment.