title: How to detect if Home Activity is currently on the top of ActivityStack
body: <p>I want to detect current foreground activity from a background service. </p>
  
  <p>Particularly I want to know if Home activity is currently on the top of android activity stack or not.</p>
  
  <p>Use case is something like: If home activity is on foreground (i.e User is not using any other application) I need to show a alert dialog on some event in background service. But if, Home activity is not on top of stack (i.e. user is using some other application), i am supposed to show a notification in status bar on some event in service.</p>
  
  <p>Is there any way to detect current foreground activity?</p>