1

How do we know if a service has stopped in a bound and unbound service?

I want to check constantly if a service has stopped and what is its state/status?

Thanks
Sneha

Smitha
  • 6,110
  • 24
  • 90
  • 161
  • http://stackoverflow.com/questions/600207/android-check-if-a-service-is-running/4976378#4976378 – John Mar 20 '12 at 05:19

1 Answers1

0

try this :

public boolean isServiceRunning(String serviceName) { 
        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); 
        List<RunningServiceInfo> infos = manager.getRunningServices(30); 
        for (RunningServiceInfo info : infos) { 
            if (info.service.getClassName().equals(serviceName)) { 
                return true; 
            } 
        } 
        return false; 
    }   
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213