Android:执行“su”无法在我的设备/模拟器中运行

时间:2013-07-13 08:48:30

标签: android exec su

我很难在代码中执行写命令:

            Process sh = Runtime.getRuntime().exec("su -c [command]");
            OutputStream os = sh.getOutputStream();

            String filePath = Environment.getExternalStorageDirectory().getPath();

            Toast.makeText(this, filePath+st+".jpg", Toast.LENGTH_SHORT).show();
            //os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
        //  os.write(("/system/bin/screencap -p " + "\"/data/data/com.example.code/files/"+filePath+".png\"").getBytes("ASCII"));
            os.write(("/system/bin/screencap -p " +filePath+st+".jpg").getBytes("ASCII"));
            os.flush();
            os.close();     
            sh.waitFor();

我已经安装了SuperUser.apk并将“su”二进制文件放在/ sdcard / Android / bin文件夹中。

Toast消息本身不会出现。我想,

1 个答案:

答案 0 :(得分:0)

答案是su不是由谷歌生成的。并且仿真器不允许java代码访问su,如果它不是原始的。虽然它在我的设备上运行良好!

相关问题