title: Bringing activity to front with an app in foreground
body: <p>As discussed <a href="https://stackoverflow.com/questions/2232238/how-to-bring-an-activity-to-foreground-top-of-stack">here</a>, I've been trying to bring an activity to the front as soon as the user tries to leave it (I'm currently using the intent inside <code>onUserLeaveHint</code>). But <code>[FLAG_ACTIVITY_REORDER_TO_FRONT][2]</code> only works if after leaving my app, the user doesn't open another app. 
  The process is somewhat as follows:</p>
  
  <pre><code>User -&gt; Activity A -&gt; User presses home button -&gt; Home screen opens -&gt; Activity A comes to front
  
  User -&gt; Activity A -&gt; User presses home button -&gt; Home screen opens -&gt; User opens Activity B -&gt; Activity A doesn't come to front
  </code></pre>
  
  <p><a href="https://play.google.com/store/apps/details?id=droom.sleepIfUCan" rel="nofollow noreferrer">Alarmy</a> has counteracted this, and I'd like to follow a similar solution.
  Any help is appreciated. Thanks in advance!</p>