Unable to input "enter" key event from within my app android
<p>I want to input "enter" key event programmatically from within my app.</p>

<p>I have tried it using abd shell command as well as using AccessibilityService, but found no luck in it.</p>

<p><a href="https://stackoverflow.com/questions/36285587/how-to-simulate-key-press-in-android-with-accessibilityservice/">Similar question was asked here as well</a></p>

<p>Below is my code which I used to execute adb shell command :</p>

<pre><code>try {
    Runtime runtime = Runtime.getRuntime();

    Process p = runtime.exec("input keyevent 66");

    BufferedReader standardIn = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader errorIn = new BufferedReader(new InputStreamReader(p.getErrorStream()));

    String output = "";
    String line;
    while ((line = standardIn.readLine()) != null) {
        output += line + "\n";
    }
    while ((line = errorIn.readLine()) != null) {
        output += line + "\n";
    }

    Log.d("output", "" + output);
} catch (IOException e) {
    e.printStackTrace();
}
</code></pre>

<p>I am getting the following output :</p>

<pre><code>sh: resetreason: can't execute: Permission denied
</code></pre>

<p>Someone please help me out.</p>

<p>If anyone knows how to achieve it using AccessibilityService as well, please let me know.</p>

<p>Thanks in advance!</p>