title: Check if service is running not behaving right
body: <p>I created a boolean to check if a service is running, if it is running I want it to show  linearlayoutA and if it is not running I want it to show another linearlayoutB.</p>
  
  <p>The problem is this, it shows the right linear layout when I start the activity, if the service is running it shows linearlayoutA if its not running it shows linearlayoutB but when I start the service in the activity it shows linearlayoutB and does not change to A even when the service as stopped until I close the application and open it. method for checking</p>
  
  <pre><code>public boolean isRunning(Class&lt;? extends Service&gt; serviceClass) {
          final Intent intent = new Intent(TimerActivity.this, serviceClass);
          return (PendingIntent.getService(TimerActivity.this, CODE, intent, PendingIntent.FLAG_NO_CREATE) != null);
      }
  </code></pre>
  
  <p>This is how I call it in onCreate of the activity</p>
  
  <pre><code>if(isRunning(TimerLocationService.class)){
              setWaitScreen(true);
          }else{
              setWaitScreen(false);
          }
  </code></pre>