You can only execute / system / bin / input as the root user or shell; this will not work in the application. The command should not start with the "adb shell" when launched from the application.
To run a command with root privileges:
Process su = null; try { su = Runtime.getRuntime().exec("su"); su.getOutputStream().write("input swipe 250 300 -800 300\n".getBytes()); su.getOutputStream().write("exit\n".getBytes()); su.waitFor(); } catch (Exception e) { e.printStackTrace(); } finally { if (su != null) { su.destroy(); } }
You should also check out third-party libraries to handle su commands: https://android-arsenal.com/details/1/451
source share