-4

Hi i am new to android application development, i want disable power button action(screen on and off) into my application. Please provide solution for this.

Raj
  • 21
  • 6

1 Answers1

0

how about override it

@Override
    public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
                    Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
                    sendBroadcast(closeDialog);
                    return true;
            }

            return super.dispatchKeyEvent(event);
    }
AbuQauod
  • 919
  • 14
  • 30