I'm doing an Android app and I would know if this was possible: When the user press the return button, it does the same action as the home button.
Asked
Active
Viewed 99 times
-1
-
the return button in the softkeyboard? – Blackbelt Jul 03 '13 at 10:03
-
the back button then? – Blackbelt Jul 03 '13 at 10:08
-
2I dont think you should override those 3 buttons with out a good reason. Are you trying to close your app down? – IAmGroot Jul 03 '13 at 10:08
-
And do you know how to do this ? I found nothing – qwertzuiop Jul 03 '13 at 10:10
-
2http://stackoverflow.com/questions/2000102/android-override-back-button-to-act-like-home-button – IAmGroot Jul 03 '13 at 10:10
-
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { Log.d(this.getClass().getName(), "back button pressed"); } return super.onKeyDown(keyCode, event); } It's the good way ? – qwertzuiop Jul 03 '13 at 10:12
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/32811/discussion-between-user1965878-and-doomsknight) – qwertzuiop Jul 03 '13 at 10:13
1 Answers
2
Following the question I linked: Override back button to act like home button:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
Should be the solution.
This overrides the backbutton, and puts the task to the back. Which emulates hiding like the home button. Read the other question for more details, and solutions.