title: How can you tell if any Activity in your application is foregrounded?
body: <p>I've got an Android app which has a periodic background Service.  I want this Service to react differently depending on whether <em>any</em> Activities in my application are open.  The issue is that the Service just keeps itself running via the <code>AlarmManager</code> making it on kind of on a separate "track" from the Activities, so I don't know whether the application is open when it runs.</p>
  
  <p>The best solution I can think of is to flip a boolean on/off whenever onResume() or onPause() is called in all my Activities, but this seems like a lot of footwork.  Is there a simpler, more elegant solution?</p>