2014-12-13 66 views
0

我想要运行超过100次的tap cmd,并且通过使用下面的代码,每次都会调用su并延迟点击。那么有可能在应用第一次启动时请求su然后快速运行许多命令?谢谢!Android超级用户访问应用程序以运行命令

try { 
    Process process = Runtime.getRuntime().exec("su"); 
    DataOutputStream os = new DataOutputStream(process.getOutputStream()); 
    String cmd = "/system/bin/input tap 350 370\n"; 
    os.writeBytes(cmd); 
    os.writeBytes("exit\n"); 
    os.flush(); 
    os.close(); 
    process.waitFor(); 

    } catch (IOException e) { 
     // TODO Auto-generated catch block 

    } 
+0

你为什么不自己尝试一下,已删除了 “* /” 之后。 – 2014-12-13 21:45:41

回答

0

这是解决方案:

try { 
    Process process = Runtime.getRuntime().exec("su"); 
    OutputStream out = process.getOutputStream(); 
    String cmd = "input tap 350 370"; 
    out.write(cmd.getBytes()); 
    out.flush(); 
    out.close(); 
    process.waitFor(); 
} catch (IOException e) { 
} catch (InterruptedException e) { 
} 

它为我

相关问题