AndroidStudio执行sushell并多次使用,避免su提示
创始人
2024-08-20 13:00:09
0

在Android Studio中执行su shell命令并多次使用,需要使用Runtime类的exec()方法来执行命令,并且需要用Process类的getOutputStream()方法来获取进程输出流,并用getInputStream()方法来获取进程输入流。另外,为了避免su toast提示,需要在第一次执行su shell命令时加入“-c”参数,并通过输出流将后续操作传递给su shell命令执行。

以下是示例代码:

try {
    Process su = Runtime.getRuntime().exec("su -c");
    DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

    // perform other Root actions here

    outputStream.writeBytes("mkdir /data/local/tmp/\n");
    outputStream.writeBytes("touch /data/local/tmp/test.txt\n");

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

相关内容

热门资讯

透视教程!wepoker底牌透... 透视教程!wepoker底牌透视脚本下载,pokemmo辅助官网,wepoke教程(都是存在有挂);...
透视肯定!wepoekr底牌透... 透视肯定!wepoekr底牌透视,aapoker透视软件,推荐攻略(有挂黑科技)1、每一步都需要思考...
透视安卓版!aapoker辅助... 透视安卓版!aapoker辅助工具存在吗,拱趴大菠萝作弊方法,力荐教程(真是存在有挂);wpk透视辅...
透视系统!智星菠萝辅助,hhp... 透视系统!智星菠萝辅助,hhpoker透视下载链接在哪里,如何分辨真伪(有挂方法)1、起透看视 hh...
透视透视!aapoker免费透... 透视透视!aapoker免费透视脚本,hhpoker软件靠谱吗,新2025教程(先前有挂);免费aa...
透视好友!智星德州菠萝插件官网... 透视好友!智星德州菠萝插件官网,aapoker辅助器是真的吗,2024教程(有挂技巧);是一款可以让...
透视智能ai!wpk有没有脚本... 透视智能ai!wpk有没有脚本,德扑圈透视,详细教程(往昔真的是有挂);建议优先通过wpk有没有脚本...
透视实锤!hhpoker透视脚... 1、透视实锤!hhpoker透视脚本安卓,wepoker辅助器怎么用,揭秘关于(有挂攻略);该软件可...
透视了解!wepoker辅助器... 【福星临门,好运相随】;透视了解!wepoker辅助器下载,佛手大菠萝有挂吗,攻略教程(先前真的有挂...
透视美元局!aapoker透视... 自定义aapoker透视插件下载系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅...