简体   繁体   English

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

[英]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.

相关问题 我的Android应用程序正在模拟器上运行,但在android设备上却无法运行 - My Android App is working on the emulator but not on the android device 我的应用在模拟器上运行正常,但在Android设备上却无法正常运行 - My App is working fine on Emulator but not on android device 我的Android应用程序在模拟器上运行,但无法在我的Android设备上运行 - My Android application runs on emulator but not working on my android device 当我的android应用程序在android设备/模拟器上运行时Jsoup无法正常工作 - Jsoup is not working when my android application is running on android device/emulator Android 4.0.3模拟器没有su - Android 4.0.3 emulator has no su ANDROID - Biometric_Not_Enrolled 在我的测试设备上不起作用,但在模拟器上起作用 - ANDROID - Biometric_Not_Enrolled not working on my test device but works on emulator 通知适用于模拟器,但不适用于我的设备 - Notification working on Emulator but not on my device 在仿真器上工作但不在真正的Android设备上 - Working on Emulator but not on the real Android device Android ListView可在模拟器上运行,但不能在设备上运行 - Android ListView working on emulator, but not on device 为什么我的应用程序在我的 android 仿真器上运行良好,但在我的真实 android 设备上运行不正常 - Why my app is working fine on my android emulator but its not working fine on my real android device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM