我正在尝试运行以下代码,我正在使用[1]:https://github.com/rbochet/Fast-Forward-Reboot此链接。
try {
Runtime.getRuntime().exec(
new String[] { "/system/bin/su", "-c", "reboot now" });
} catch (IOException e) {
e.printStackTrace();
}
错误 W / System.err:java.io.IOException:运行exec()时出错。命令:[/ system / bin / su,-c,now now]工作目录:null环境:null。
权限
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_INTERNAL_STORAGE
android.permission.READ_INTERNAL_STORAGE
android.permission.REBOOT.
我正在使用Android Studio,目标Android 6.0(API级别23) 任何人请有个主意。提前谢谢。
答案 0 :(得分:1)
将"/system/bin/su"
替换为"/system/xbin/su"
答案 1 :(得分:0)
/**
* Checks if the device is rooted.
*
* @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
*/
public boolean isRooted() {
// get from build info
String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys")) {
return true;
}
// check if /system/app/Superuser.apk is present
try {
File file = new File("/system/app/Superuser.apk");
if (file.exists()) {
return true;
}
} catch (Exception exception) {
// ignore
exception.printStackTrace();
}
String[] commands = {
"/system/xbin/which su",
"/system/bin/which su",
"which su"
};
for (String command : commands) {
try {
Runtime.getRuntime().exec(command);
return true;
} catch (Exception exception) {
exception.printStackTrace();
}
}
Log.d("message-startUp: ", "RootUtil");
return false;
}
如果您的设备无根,则仍会出现同样的错误