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.
Asked
Active
Viewed 1,367 times
-4
-
You can't with stock OS – Zoe Aug 16 '17 at 06:50
-
And why would you want to do that? :? – Alessio Aug 16 '17 at 06:55
1 Answers
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