如何为有根的安卓设备覆盖红外遥控器的电源键?我尝试了以下方法
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;
但以上这些都不起作用。我错过了什么吗?
尝试记录密钥,以便获得要处理的实际 KeyEvent。例如:
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
Log.d("keycode", "" + keyCode);
(...)
}