under
under

Reputation: 3087

Android TV emulator not recognizing media key events

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?

Directional pad extended control in Android TV emulator

Upvotes: 3

Views: 1217

Answers (1)

Maddis
Maddis

Reputation: 645

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.

Upvotes: 4

Related Questions