title: Check if Foreground service is running in Android OREO
body: <p>I want to check whether my service is running in or not, 
  I was using below code which was working fine till nougat but not working in OREO</p>
  
  <pre><code> private boolean isMyServiceRunning(Class&lt;?&gt; serviceClass, Context context) {
          ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
          for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
              Log.d(TAG, "isMyServiceRunning: " + service.service.getClassName());
              if (serviceClass.getName().equals(service.service.getClassName())) {
                  return true;
              }
          }
          return false;
      }
  </code></pre>
  
  <p>But above code is not working for foreground services.</p>
  
  <p>I have referred <a href="https://stackoverflow.com/questions/6452466/how-to-determine-if-an-android-service-is-running-in-the-foreground">this</a> but it is also not working..</p>