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 minimize on back key pressed
@Override
public boolean onKeyDown(int keyCode, keyEvent event) {
switch(keyCode) {
case KeyEvent.KEYCODE_BACK;
//minimize application
return true;
}
return super.onKeyDown(keyCode, event);
}
This is a simple code to minimize the application
I think that you need to treat
back
event ashome
event. The code below is how I emulatehome
pressed when User pressback
button:try this code, this will minimize Activity.
or
If you want to close the activity use
this.finish()
method to close the current running activity. instead ofthis.moveTaskToBack(true);