I have this event handler in my activity:
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
//do something
return true;
case KeyEvent.KEYCODE_MEDIA_REWIND:
//do something
return true;
default:
return super.onKeyUp(keyCode, event);
}
}
While debugging in Android TV device emulator, I can see KEYCODE_DPAD_LEFT and KEYCODE_MEDIA_PLAY_PAUSE when I press a button in directional pad extended control.
But when I press "fast forward" or "rewind" media keys, the key up event is triggered, but the key code is "unrecognized".
KeyEvent { action=ACTION_UP, keyCode=KEYCODE_UNKNOWN, scanCode=208...
Is this a Google bug or am I doing something wrong here?
It seems that the TV Emulator actually does not provide the correct keycode here, which seems to be a bug.
You can simulate this via the command line:
adb shell input dpad keyevent 90
This will trigger the KEYCODE_MEDIA_FAST_FORWARD
button.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.