1Create the method:
2
3private boolean isMyServiceRunning(Class<?> serviceClass) {
4 ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
5 for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
6 if (serviceClass.getName().equals(service.service.getClassName())) {
7 return true;
8 }
9 }
10 return false;
11}
12
13And I call it using:
14isMyServiceRunning(MyService.class)
15