Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable power button?

Is it possible to override the functionality of the android power button ? I want to 'disable' the power button. My plan is to override the functionality of this button to do nothing ( {}; ) Well my main idea is to disable the turning the screen off.

I want when someone press the power button nothing to happen.

How can I do this ?

like image 838
Lukap Avatar asked Nov 07 '11 12:11

Lukap


2 Answers

Is it possible to override the functionality of the android power button ? I want to 'disable' the power button.

Fortunately, this is not possible, except perhaps via custom firmware.

like image 191
CommonsWare Avatar answered Sep 17 '22 17:09

CommonsWare


It works on Cyanogenmod: http://review.cyanogenmod.com/#/c/18924/4/core/res/AndroidManifest.xml you would need the android.permission.PREVENT_POWER_KEY permission.

Btw one good scenario is to use the power button as a camera shutter button (if the device does not have a dedicated one).

Afaik system apps can intercept the power button normally.

like image 28
user765269 Avatar answered Sep 16 '22 17:09

user765269