Strong Root

Activity 내부에 아래와 같이 작성하고,

 

1
2
3
4
5
6
7
8
9
private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
cs

 

 

 

 

 

 

아래와 같이 call 한다.

 

isMyServiceRunning(MyService.class)
cs

 

 

 

 

 

 

 

출처 : http://stackoverflow.com/questions/600207/how-to-check-if-a-service-is-running-on-android