2013-10-18 55 views
0

如何覆蓋紅外遙控器的電源鍵以查找已安裝Android的設備?我曾嘗試以下方式安卓紅外遠程覆蓋電源鍵

  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; 

但是以上都無效。我錯過了什麼?

回答

0

嘗試記錄密鑰,以便獲得要處理的實際KeyEvent。例如: :

@Override 
public boolean onKeyUp(int keyCode, KeyEvent event) { 
    Log.d("keycode", "" + keyCode); 
(...) 
}