does not close android app by pressing back button
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2354336/android-pressing-back-button-should-exit-the-app">android pressing back button should exit the app</a>  </p>
</blockquote>



<p>I am trying to close an app using mobile's back button. Currently I am overriding <code>onKeyPressed</code> method and calling <code>moveTaskToBack(true);</code>. It does hides the app but does not close it. It still remains in the memory. How can I close the app by pressing the back button?</p>

<p>Here is my  code</p>

<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        moveTaskToBack(true);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
</code></pre>
