監聽不到android 的 Home 鍵

應用程序監聽不瞭android 機的HOME KEY事件。

 

 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
  // TODO Auto-generated method stub
  if(keyCode==3)//HOME鍵碼為3
  {
   HomeKeyNum+=1;
   Log.i("gogler", "home key pressed time is: "+HomeKeyNum);
  }
  return super.onKeyDown(keyCode, event);
 }

 

實驗結果沒有預期日志輸出,把鍵碼換成BACK鍵碼4則可以監聽到。

 

官方解釋:

Key code constant: Home key. This key is handled by the framework and is never delivered to applications.

 

摘自 gogler的專欄

發佈留言