public  void RunCmd(String mycmd)
    {

        Process su = null;
        try {
            su = Runtime.getRuntime().exec("su");
        } catch (IOException e) {
            e.printStackTrace();
        }
        DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

        try {
            outputStream.writeBytes(mycmd+"\n");
            outputStream.flush();

            outputStream.writeBytes("exit\n");
            outputStream.flush();
            try {
                su.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }


    }

  

相关文章:

  • 2021-11-09
  • 2021-11-19
  • 2021-09-06
  • 2021-04-01
  • 2021-09-03
猜你喜欢
  • 2022-12-23
  • 2021-09-22
  • 2021-07-23
  • 2021-07-27
  • 2021-08-06
  • 2021-07-26
相关资源
相似解决方案