How to differentiate between long key press and regular key press?
问题 I'm trying to override the functionality of the back key press. When the user presses it once, I want it to come back to the previous screen. However, when the back key is long-pressed (for, let's say, two seconds or more), I want to exit the application. By now, I have overriden these two methods in my activity: @Override public boolean onKeyDown( int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK) { //manage short keypress return true; } return super.onKeyDown(keyCode, event