title: How to check if an external app is running on foreground?
body: <p>I am trying to build an application in which a service can check whether an <strong>external application</strong> is running at foreground or not.</p>
  
  <p>For example, when we enter in Google Chrome, this service automatically detects what package has been executed and reacts in one way or another.</p>
  
  <ul>
  <li>It's that even possible?</li>
  <li>I have heard about 'getRunningTasks' method but is deprecated on new Android versions</li>
  </ul>
  
  <p>Any suggestion is appreciated.</p>