0

I'm developing a simple app on PhoneGap for an Android set top box.

I have an image that is usable as a link. When I connect a mouse to the set top box and click the image, the link works. But when I use the remote control and select the image (I see the border around the image so I know it is selected) and I click OK button, the link does not work.

How can I use the remote buttons in the code?

KatieK
  • 13,586
  • 17
  • 76
  • 90
nimi
  • 917
  • 2
  • 14
  • 28

1 Answers1

1

This is very tricky because Google didn't feel like mapping the keys on a remote to an actual key output.

To use the setTopBox, you're going to have to figure out what key codes your Android Set Top Box is using and modify the Activity's onKeyUp event to handle it. We currently have an example of a work-around in this bug however we don't have an agreed API for exposing these buttons to Javascript yet, which is why this bug is still open.

But in short, you'd do something like this:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_DPAD_UP) 
  {
    sendJavascript("javascript:myJsMethod('UP');"); 
    return true; 
  }

  return super.onKeyDown(keyCode, event);
}
Joe B
  • 596
  • 4
  • 11