Reputation: 31
I want to prevent opening shutdown menu in android and knows maybe isn't possible. I my solution I want prevent shutdown android device by android menu
I have two ideas :
Any code for checking Power key not work like this in new android version :
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyPressed = event.getKeyCode();
if(keyPressed==KeyEvent.KEYCODE_POWER){
Log.d("###","Power button long click");
Toast.makeText(MainActivity.this, "Clicked: "+keyPressed, Toast.LENGTH_SHORT).show();
return true;}
else
return super.dispatchKeyEvent(event);
}
Do you have any idea for this problem because my app isn't system app(non root device)?
Upvotes: 0
Views: 79