Back button and last activity
<p>My app chains some activities. </p>

<p>if you press the back button, you go back through old activities then you suddenly quit the application !</p>

<p>so I need to show a message like "do you really want to exit" if it's the last activity on stack</p>

<p>I know how to override the back button but i can't figure how to know how many activity are in history</p>

<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; event.getRepeatCount() == 0) {
        // Is it the last activity on stack ? 
        // so show confirm dialog
        return true;
    }

    return super.onKeyDown(keyCode, event);
}
</code></pre>

<p>Please help.</p>
