title: Disable the power button in activity
body: <p>I'm developing an app in which there is a requirement to not let the user to lock the screen or turn off the android device using power button,so I have to disable the power button and over ride the power button functionality, I have searched alot on internet as well but can't find anything.I have used these two pieces of code but still it did not work for me.</p>
  
  <pre><code> @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
                if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
                        Log.i("", "Dispath event power");
                        Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
                        sendBroadcast(closeDialog);
                        return true;
                }
  
                return super.dispatchKeyEvent(event);
        }
        public boolean onKeyDown(int keyCode, KeyEvent event)
        {
            if (keyCode == KeyEvent.KEYCODE_POWER) {
                  // Back
                  moveTaskToBack(true);
                  return true;
              }
  
              else {
                  // Return
  </code></pre>
  
  <p>Please help me thanks in advance.                  </p>