title: Disable the buttons of an Android Device when an app is running
body: <p>I'm developing an application and I need to <strong>disable the virtual buttons</strong> when the application started to run since there are buttons from the application.</p>
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.activity_1st_main);
      
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
  
  @SuppressWarnings({ &quot;unchecked&quot;, &quot;rawtypes&quot; })
  private final List hijackKeys = new ArrayList(Arrays.asList(
          KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_UP,
          KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_HOME));
  
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
      if (hijackKeys.contains(event.getKeyCode())) {
          return true;
      } else {
          return super.dispatchKeyEvent(event);
      }
  }
  </code></pre>
  <p><img src="https://i.stack.imgur.com/HMGqo.png" alt="enter image description here" /></p>