I have tried the following ways to Override the HOME Button:-
By using KeyDown method.
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.e("Pressed", "" + keyCode); if (keyCode == KeyEvent.KEYCODE_HOME) { Log.e("HOME_PRESSED", "Ignoring HOME Button."); return true; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Log.e("BACK_PRESSED", "Ignore back pressing."); return true; } return super.onKeyDown(keyCode, event); }
By using NewIntent method.
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.getAction().equalsIgnoreCase(Intent.ACTION_MAIN)) { Log.e("MAIN_PRESSED", "Ignoring MAIN Button."); } }
But I am unable to Override the HOME Button Press Event.
So, as per my knowledge and by Logs I figured out that everytime I press Home button.
It fires ACT-AM_ON_PAUSE_CALLED
. (Unaware about it)
I tried to Google this thing to know more about it but nothing relevant found!.
Please help to Override the HOME Button in application.