I am developing android application with lock functionality. please suggest me how to disable all the hard keys programatically. here i am using beleow code to disable back
for back button (in activity or fragment)
@Override
public void onBackPressed() {
}
Override home button in android/ Disable home button in android/Stay on your activity while clicking home button in android
@Override
public void onAttachedToWindow(){
Log.i("TESTE", "onAttachedToWindow");
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
public boolean onKeyDown(int keyCode, KeyEvent event){
if (keyCode == KeyEvent.KEYCODE_HOME) {
Log.i("TESTE", "BOTAO HOME");
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch( event.getKeyCode() ) {
case KeyEvent.KEYCODE_MENU:
result = true;
break;
case KeyEvent.KEYCODE_VOLUME_UP:
result = true;
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
result = true;
break;
case KeyEvent.KEYCODE_BACK:
result = true;
break;
default:
result= super.dispatchKeyEvent(event);
break;
}
return result;
}
and check this also