What would be the best way to check if an Android Service is running? I am aware of the ActivityManager
API, but it seems like the use of the API is not advised for
Another method:
public static boolean isServiceRunning(Context ctx, String serviceClassName) {
ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (TrackingService.class.getName().equals(serviceClassName)) {
return true;
}
}
return false;
}