Search code examples
androidlockscreenandroid-homebutton

Android disable all hardware keys for lockscreen app


I am coding a custom lockscreen app for android.

I have managed to disable the back button. But the home button and the recent apps button on ICS proved not to be as easy.

I searched around and came up with:

@Override
public void onAttachedToWindow() {
    // TODO Auto-generated method stub
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    super.onAttachedToWindow();
}

However, this throws IllegalArgumentException window type can not be changed after it is added. I then tried to set it in onCreate() but the home key still functions.

I am willing to use root methods to achieve this. Is there any way to get it done?

Any help would be appreciated!


Solution

  • For android versions above 2.3, overriding of the Home button is disabled