Reputation: 119
I am sincerely trying to display alert box
onClick of Home key
, but I am not succeeded. So please help me to write the code otherwise, show me the code.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK )
{
finish();
return false;
}
else if (keyCode == KeyEvent.KEYCODE_HOME)
{
finish();
return false;
}
return super.onKeyDown(keyCode, event);
}
Upvotes: 0
Views: 1066
Reputation: 9033
I don't think you can intercept HOME key presses. It is reserved to ensure that you don't get locked within any application.
KEYCODE_HOME
: This key is handled by the frame work and is never delivered to applications.
So you can't use it
Upvotes: 0
Reputation: 2408
it is not possible to intercept KEYCODE_HOME by external applications: http://code.google.com/p/android/issues/detail?id=1979
Upvotes: 2