-3

I am working in an launcher application ,In which i have to disable the home button event. How can we do this in android 4.0 and above.

Renjith
  • 5,783
  • 9
  • 31
  • 42
Anand
  • 1
  • 1
  • 2
  • possible duplicate of [Override home and back button is case a boolean is true](http://stackoverflow.com/questions/10025660/override-home-and-back-button-is-case-a-boolean-is-true) – Siddharth Lele May 16 '13 at 12:05
  • possible duplicate of [How to disable the home key](http://stackoverflow.com/questions/3898876/how-to-disable-the-home-key) – Useless May 16 '13 at 15:26

3 Answers3

2

There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.

If you want to handle the HOME button, implement a home screen.

For more information check the link below. check the answer by commonsware

Not able disable Home button on specific android devices

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
0

Here you have ;)

public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_HOME) 
        {

            return true;
        }

        return super.onKeyDown(keyCode, event);
    }

You should use this in your activities.

  • 1
    From the [docs](http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME): *This key is handled by the framework and **is never delivered to applications**.* – adrianp May 16 '13 at 12:03
0

You could use the method onPause() onPause

So if you press Home and return to you app you can run whatever you want. Maybe it helps

Oli
  • 3,496
  • 23
  • 32