-2

I am working on Pattern Lock App. I want to Disable home, app switch menu and back buttons on lock-screen Activity actually These button are not disable in KitKat, Jelly Bean and other device all button disable instead of home button.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • I have posted my answer here http://stackoverflow.com/questions/34919013/how-to-disable-virtual-home-button-in-any-activity/34925204#34925204 check this. – hardwork Jan 21 '16 at 13:32

1 Answers1

0
// 2.0 and above
@Override
public void onBackPressed() {
    //task to do in back button pressed
    //moveTaskToBack(true);
}

// Before 2.0
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        //task to do in back button pressed
        //moveTaskToBack(true);
        return true;
    }
    else if (keyCode == KeyEvent.KEYCODE_HOME) {
        //task to do in home button pressed
        return true;
    }

    else if ( keyCode == KeyEvent.KEYCODE_MENU ) {
        //task to do in menu button pressed
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Dinithe Pieris
  • 1,822
  • 3
  • 32
  • 44