I need to simulate tap event on android using command. I use this code but it is not working:
public Boolean execCommands(String... command) {
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
for(int i = 0; i < command.length; i++) {
os.writeBytes(command[i] + "\n");
os.flush();
}
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (IOException e) {
return false;
} catch (InterruptedException e) {
return false;
}
return true;
}
where command is:
String[] commands = {
"/system/bin/input tap 250 450",
"/system/bin/input tap 250 450"
};
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
Phone is properly rooted and acces in superuser is granted