I am trying to capture app switch key and home key on android 3.1 and 4.0 but it doesn't seem like its working.
here is what I am doing
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (KeyCode == KeyEvent.KEYCODE.KEYCODE_APP_SWITCH && event.getRepeatCount() == 0)
{
Log.d ("onkeydown","app switch key");
}
else if (KeyCode == KeyEvent.KEYCODE.KEYCODE_HOME && event.getRepeatCount() == 0)
{
Log.d ("onkeydown","home key");
}
//EDIT:
return super.onKeyDown(keyCode, event);
}
My log.d statement is not printed. Is it possible to capture these 2 keys?
updated code with correct return statement
Um.
Well, no, you can't.
public static final int KEYCODE_HOME
Since: API Level 1
Key code constant: Home key.
This key is handled by the framework and is never delivered to applications.
http://developer.android.com/reference/android/view/KeyEvent.html