2

I am trying to run below code,I am using [1]:https://github.com/rbochet/Fast-Forward-Reboot this link.

 try {
        Runtime.getRuntime().exec(
                new String[] { "/system/bin/su", "-c", "reboot now" });
    } catch (IOException e) {
        e.printStackTrace();
    }

And Error W/System.err﹕ java.io.IOException: Error running exec(). Command: [/system/bin/su, -c, reboot now] Working Directory: null Environment: null.

PERMISSIONS

android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_INTERNAL_STORAGE
android.permission.READ_INTERNAL_STORAGE
android.permission.REBOOT.         

I am using Android Studio ,Target Android 6.0 (API level 23) Anybody please have an idea. thanks in advance.

nilesh shinde
  • 23
  • 1
  • 4

2 Answers2

0

replace "/system/bin/su" to "/system/xbin/su"

Android Android
  • 724
  • 1
  • 7
  • 20
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;
    }

if your device unrooted, still will bring up the same error

Eka putra
  • 739
  • 10
  • 15