我正在尝试通过发送触摸命令来使服务控制另一个应用程序的操作。这是我实现它的方式:
try {
StringBuilder strB = new StringBuilder();
strB.append("input swipe ");
strB.append(x);
strB.append(" ");
strB.append(y);
strB.append(" ");
strB.append(x);
strB.append(" ");
strB.append(y);
strB.append(" ");
strB.append("1000\n");
String val = strB.toString();
process = Runtime.getRuntime().exec("su");
stream = new DataOutputStream(process.getOutputStream());
stream.writeBytes(val);
stream.writeBytes("exit \n");
stream.flush();
stream.close();
process.waitFor();
process.destroy();
long mem = Runtime.getRuntime().freeMemory();
Log.e("Memory: ", "" + mem);
Log.e("Final values: ", val);
} catch (Exception e) {
System.err.println("IOException: " + e.getMessage());
}
该服务可以运行并能够控制我想要的应用程序,但问题是,在一段时间内,应用程序崩溃并弹出此错误:
E/memtrack( 6164): Couldn’t load memtrack module (No such file o directory)
E/android.os.Debug( 6164): failed to load memtrack module: -2
E/Watchdog( 2326): !@Sync 141
如果有人对此有任何见解或解决方案,我们将非常感谢您的帮助。