Why are you configuring category HOME in your manifest ? You can override home pressing behavior by overriding :
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_HOME)) {
Toast.makeText(this, "Home button pressed!", Toast.LENGTH_LONG).show();
return true;
}
return super.onKeyDown(keyCode, event);
}
Then just do whatever it is you're doing when pressing the button inside the app. Outside the app it will work normally of course.
EDIT
Just checked it, doesn't work on my device, but it seems like if you override onAttachedWindow()
and disable HOME, it might do the trick. Just remember to reassign the key using onKeyDown()
(just like posted above this edit).
@Override
public void onAttachedToWindow() {
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}