How To Handle Home Button In Android

mohamed picture mohamed · Jun 3, 2012 · Viewed 15.1k times · Source

I Am a New Android Developer, I know Handle The Back Button but I Don't Know How To Handle Home Button, when I Clicked Home Button, I Tried a Lot Of Methods, But Not Used, Please Any One Help To Me and Solve My Problem. I have used following code,

 @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) 
  {
    if(keyCode==KeyEvent.KEYCODE_HOME)
    {
        Toast.makeText(this, "Click Home ", Toast.LENGTH_LONG).show();
    }
    return super.onKeyDown(keyCode, event);
   }

Answer

Parag Chauhan picture Parag Chauhan · Jun 3, 2012

You Does not get Home Button click event .But When u press Home Button call this method

  @Override
        protected void onStop() {

            super.onStop();
        }