Long key press handling in android 1.5
- by Kaillash
Hi,
I want to handle key press and long key press for the key code KEYCODE_BACK(back button). can any one suggest me how to do this in android 1.5(API level 3).
Here is the code.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if(event.getRepeatCount()==0) {
// normal key press
// But problem is, this code is hitting for long press also, how to avoid this
} else {
// Long key press
//Do something here
}
// Always consume back key event by returning true
//so that default behavior of back is overrided
return true;
}
return super.onKeyDown(keyCode, event);
}