ROOT shell su 支持中文输入 直接执行并输出结果 【基哥代码】
String su(String su){String r=;
try
{
java.lang.Process p = Runtime.getRuntime().exec("su");
DataOutputStream d = new DataOutputStream(p.getOutputStream());
d.write(new StringBuffer().append(su).append("\n").toString().getBytes("UTF-8"));
d.writeBytes("exit\n");
d.flush();
StringBuilder i = new StringBuilder();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s;
while ((s = b.readLine()) != null)
{
i.append(s);
}
p.getErrorStream().close();
r=i.toString();
}catch (IOException e){}
return r;
} TextView tv=(TextView)findViewById(R.id.mainTextView1); tv.setText(su(s));
页:
[1]