Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:&quo

Code to check is Device rooted or not,Android.

write these two lines inside onCreate() method:
boolean isRooted=isRooted();
        System.out.println("---------isRooted----------"+isRooted);
------------------and use below methods
/**
     * Checks if the device is rooted.
     *
     * @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
     */
    public static 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 e1) {
        // ignore
      }

      // try executing commands
      return canExecuteCommand("/system/xbin/which su")
          || canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su");
    }

    // executes a command on the system
    private static boolean canExecuteCommand(String command) {
      boolean executedSuccesfully;
      try {
        Runtime.getRuntime().exec(command);
        executedSuccesfully = true;
      } catch (Exception e) {
        executedSuccesfully = false;
      }

      return executedSuccesfully;

    }

Comments

  1. Hi Pavan

    Exactly what I was looking for.
    Your points seem very good and sure it will helpful for many people.

    Regards,
    Bala.

    ReplyDelete

Post a Comment