【问题标题】:Tap Input Emulation Programmatically以编程方式点击输入仿真
【发布时间】:2014-05-26 21:42:21
【问题描述】:

我正在尝试让我的服务模拟点击输入,但它不起作用。

我的主要活动已经调用

try {

            Runtime.getRuntime().exec("su");

        } catch (IOException e) {

            e.printStackTrace();

        }

我的服务检查是否点击了我想调用的切换按钮

try {

                Runtime.getRuntime().exec("input tap" + Main.xValue.toString() + Main.yValue.toString());

            } catch (IOException e) {

                e.printStackTrace();

            }

但是没有成功,有人能解释一下原因吗?

【问题讨论】:

标签: android eclipse string shell root


【解决方案1】:

举个例子: Main.xValue.toString() = 10 Main.yValue.toString() = 20

所以根据你的代码,行:

"input tap" + Main.xValue.toString() + Main.yValue.toString()

将是“输入 tap1020”

但您期望“输入抽头 10 20”!

试试:

try {
     Runtime.getRuntime().exec("su -c input tap " + Main.xValue.toString() + " " + Main.yValue.toString());
} catch (IOException e) {
     e.printStackTrace();
}

【讨论】:

    猜你喜欢
    • 2021-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-03
    • 2015-01-04
    • 2016-07-27
    • 1970-01-01
    • 2017-08-26
    相关资源
    最近更新 更多