Android: Runtime.getRuntime().exec(String) 命令太慢?或者我做错了什么?

Android: Runtime.getRuntime().exec(String) command is too slow? or I am doing something wrong?

我正在尝试创建一个应用程序,我用它来远程控制 android 设备(电视)。实际上我做到了,但是当我点击控制器设备(移动设备)上的按钮时,它需要 apprx。 1 秒完成我想要控制的设备(电视)中的工作。

当我检查代码中的所有日志时,我发现该方法花费了那么多时间...

    String commandStr;
    commandStr = String.format("%s"," input keyevent "+keyCode);

    try {
        process = runTimeExec(commandStr);
        runTimeExec(commandStr);
    } catch (IOException e) {
    }

而 运行TimeExec 定义为;

    public static Process runTimeExec(String commandStr) throws IOException {  
           Runtime.getRuntime().exec(commandString);

    }

我只想知道是否有任何其他解决方案可以立即在电视设备上执行 运行 命令?或者我怎样才能使这段代码更快?

我为此使用了 getevent/sendevent 代码。它非常快,可以立即在电视设备上运行。就试一试吧。您可以在 https://source.android.com

中找到详细的文档