title: Android: How can I detect if the Back button will exit the app (i.e. this is the last activity left on the stack)?
body: <p>I'd like to warn the user if the back press is going to finish the last activity on the stack, thereby exiting the app. I'd like to pop up a little toast and detect a 2nd back press within the next few seconds and only then call <code>finish()</code>.</p>
  
  <p>I already coded the back press detection using <code>onBackPressed()</code>, but I can't find an obvious way to see how many activities are left on the back stack.</p>
  
  <p>Thanks.</p>