mytechead

Android & Wordpress Help center

Disable HOME KEY in android

In order to disable the home button or the home key on your android device you can use the following piece of code.

 

@Override
public void onAttachedToWindow()
{

this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
 return true;
}
return super.onKeyDown(keyCode, event);
}

 

This disables the home button.

 

Hope it helps some one!!

Advertisements

Single Post Navigation

3 thoughts on “Disable HOME KEY in android

  1. Very neat! Thanks for the tip.

  2. ramesh on said:

    its not working for android 4.0.1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: