59 6f 75 20 61 72 65 20 61 20 63 75 72 69 6f 75 73 20 6f 6e 65 21 20 57 65 6c 63 6f 6d 65 20 74 6f 20 6d 79 20 70 65 72 73 6f 6e 61 6c 20 62 6c 6f 67 2e
May 16, 2015
The second snippet is… -drum roll- How to know if a service is running in Android!
Check this:
public 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; }
true if the service is running, false if not.