Possible Duplicate:
OnTouchListener, ACTION_UP fires automatically after 30 second timeout
I use the following code to check if a key is clicked:
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// Little method to allow the sound to be changed
if(keyCode == 24 || keyCode == 25) {
return false;
}
if(event.getAction() == KeyEvent.ACTION_DOWN) {
// if(resetKeyPress != true) {
this.keyCode = keyCode;
// resetKeyPress = true;
if(this.logGameEngineInputLog == true) {
gameEngineLog.d(classTAG, "Pressed down " + this.keyCode);
}
// }
}
else if(event.getAction() == KeyEvent.ACTION_UP){
//waitUntilReleased = false;
//this.changeKeyCode(null);
if(this.logGameEngineInputLog == true) {
gameEngineLog.d(classTAG, "Released key " + this.keyCode);
}
this.keyCode = null;
// resetKeyPress = false;
}
return true;
}
When I click a button for a long time, it keeps on saying a button is pressed, however after a while it says the key has been released, even though I'm still holding down the key. Why is it doing this? Is there a way to prevent this? Is this being done on purpose by the Android OS, if so, why?