title: How to perform action KeyEvent.ACTION_DOWN in Android M
body: <p>I am using Android M (Galaxy S6). I have an activity that will perform the action down (similar when we press the physical down button/volume down). Without any press the physical button, I want to perform the action by code in Android M. This is my code but it does not work. Could you help me to fix it? Note that, I do not want to use any root permission</p>
  
  <p>First way:</p>
  
  <pre><code> BaseInputConnection mInputConnection = new BaseInputConnection(findViewById(R.id.button), true);
                      KeyEvent down = new KeyEvent(now, now, KeyEvent.ACTION_UP,KeyEvent.KEYCODE_HOME, 0);
                      mInputConnection.sendKeyEvent(down);
  </code></pre>
  
  <p>Second way:</p>
  
  <pre><code>Runtime.getRuntime().exec("input keyevent " +
       Integer.toString(KeyEvent.ACTION_DOWN));
  </code></pre>