I have a Ticwatch E connected using ADB and I'm viewing the logcat. There is only one button on this device but when I press it, my onKeyDown method does not fire. I've been reading the Android documentation on Physical buttons, and have followed what they have specified. Here is my code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d(TAG, "onKeyDown: keyCode=" + keyCode + "; keyEvent=" + event.toString());
if (event.getRepeatCount() == 0) {
if (keyCode == KeyEvent.KEYCODE_0) {
Log.d(TAG, "ShowTokenActivity.onKeyDown: KeyEvent.KEYCODE_0");
} else if (keyCode == KeyEvent.KEYCODE_1) {
Log.d(TAG, "ShowTokenActivity.onKeyDown: KeyEvent.KEYCODE_1");
} else if (keyCode == KeyEvent.KEYCODE_2) {
Log.d(TAG, "ShowTokenActivity.onKeyDown: KeyEvent.KEYCODE_2");
} else if (keyCode == KeyEvent.KEYCODE_3) {
Log.d(TAG, "ShowTokenActivity.onKeyDown: KeyEvent.KEYCODE_3");
}
}
return super.onKeyDown(keyCode, event);
}
My stackoverflow searching uncovered this:
I also read Use Key Events Directly from the android developer site which has an example with similar code to what I have above. The only difference is that the Activity class is final.