title: How to check if activity is in foreground or in visible background?
body: <p>I have a splash screen on a timer. My problem is that before I <code>finish()</code> my activity I need to check that the next activity has started because a system dialogue box pops-up and I only want to <code>finish()</code>; once the user has selected an option from the dialogue box? </p>
  
  <p>I know that there are many questions on how to see if your activity is in the foreground but I do not know if this allows for dialogue boxes on top of the activity too. </p>
  
  <p>Here is the problem, the red is my activity which is in the background while the dialogue is in the foreground:</p>
  
  <p><img src="https://i.stack.imgur.com/wHSzj.png" alt="the red is my activity which is in the background while the dialogue is in the foreground"></p>
  
  <p><strong>EDIT:</strong> I have tried just not using <code>finish()</code> but then my activity can be gone back to in the stack of applications which I am trying to avoid.</p>