0

如何为已植根的 Android 设备覆盖 IR 遥控器的电源键?我试过以下

         case KeyEvent.KEYCODE_STB_POWER:
            Toast.makeText(this, "KEYCODE_STB_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_AVR_POWER:
            Toast.makeText(this, "KEYCODE_AVR_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_TV_POWER:
            Toast.makeText(this, "KEYCODE_AVR_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_POWER:
            Toast.makeText(this, "KEYCODE_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

但以上都没有奏效。我错过了什么吗?

4

1 回答 1

0

尝试记录密钥,以便获得要处理的实际 KeyEvent。例如:

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.d("keycode", "" + keyCode);
(...)
}
于 2013-10-24T09:02:22.803 回答