0

I have developed a pattern lock android application. It is working fine.

In home screen, pattern is displayed. User could get through the lock only after unlocking with correct pattern(just like normal pattern lock).But the problem here is ,when the user presses 'home' button,the app closes.

I disabled back button.But couldn't find anywhere to disable 'home' button.

Could anyone provide me a solution?

guipivoto
  • 18,327
  • 9
  • 60
  • 75
  • 1
    Possible duplicate of [Disable home button in android toddler app?](http://stackoverflow.com/questions/4278535/disable-home-button-in-android-toddler-app) – ste-fu Jul 19 '16 at 10:32

1 Answers1

0

Try this code

Override the below method in your Activity,

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);           
}

And handle the key event

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
   if(keyCode == KeyEvent.KEYCODE_HOME)
    {
     Log.i("Home Button","Clicked Home button");
    }
 return false;
}
Android Surya
  • 544
  • 3
  • 17