According to android documentation, detecting key release should be as simple as:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
System.out.println("pressed");
event.startTracking();
return true;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
System.out.println("released");
return true;
}
but when trying to implement it, it doesn't work as expected.
I need to detect when a key of a bluetooth keyboard is pressed and receive only one call to onKeyDown when that happens, and detect when that same key is released. I'm I doing something wrong, or is there any other way to get this desired result?
When pressing and holding down any key, I get this repeatedly on console:
I/System.out: pressed
I/System.out: released
I/System.out: pressed
I/System.out: released
I/System.out: pressed
I/System.out: released
I/System.out: pressed
I/System.out: released
Thanks.