监听不到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.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjggw.html