I need to minimize the application when back button is pressed.
I use following code to catch hardware back button click event
help me with the code of min
try this code, this will minimize Activity.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
{
this.moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
or
If you want to close the activity use this.finish()
method to close the current running activity. instead of this.moveTaskToBack(true);