[英]Android: Execute “su” not working in my device/emulator
I am stuck with executing a write command in the code: 我一直坚持在代码中执行写命令:
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();
I have installed SuperUser.apk and placed the "su" binary file in /sdcard/Android/bin folder. 我已经安装了SuperUser.apk,并将“ su”二进制文件放在/ sdcard / Android / bin文件夹中。
The Toast message itself is not coming up. Toast消息本身没有出现。 I guess,
我猜,
The answer is that the su is not generated by google. 答案是su不是由Google生成的。 And the emulators wouldn't allow a java code to access the su if its not original.
如果模拟器不是原始版本,那么仿真器将不允许Java代码访问su。 It worked fine with my device though!
虽然可以在我的设备上正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.