So when Power button is pressed one time then the screen is off or basically locked. I would like to alter this behavior so that if power button is pressed then the screen should not go off. As per discussion here it is not possible Stop the Screen Locking when power button is pressed but then what I have is a rooted one. Is there a solution where I can use su privileges to achieve this somehow?
So far I tried this code snippet but this is not invoked when power button is clicked only once. If I do a long press on Power button then I can get to this but my objective is to get to it for just one click.
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
//dostuff
return true;
}
return super.dispatchKeyEvent(event);
}
Any Suggestions?