Android how to check phone rooted or not ?

Hi, Developer in this Android example we have toking abut check phone is rooted or not. Today for security ist very importation to check your application run on the rooted phone on not. Because Android is a Linex base show hacker collects user data after boot phone and runs Android Application.

A show we make an Android solution for check program moile phone rooted or not. If the phone is not rooted App is running else App not run.

We are sharing Two ways how to check the phone is rooted or not in android programmatically.How to determine if running on a rooted device or not in Android?

  1. Using Third-party Library you can used it.
  2. Self writes custom code for root deduction.

So, Lets Start on Topic

1.  First Way Using Third-party Library RootBeer you can use.

Use Follow Two simple steps and Implication these.

Root checks

These are the current checks/tricks we are using to give an indication of the root.

Java checks

  • checkRootManagementApps
  • checkPotentiallyDangerousApps
  • checkRootCloakingApps
  • checkTestKeys
  • checkForDangerousProps
  • checkForBusyBoxBinary
  • checkForSuBinary
  • checkSuExists
  • checkForRWSystem

Step 1:   Add rootBeer third-party library in your App girdle file.

dependencies {
    implementation 'com.scottyab:rootbeer-lib:0.0.8'
}

Step 2: And add this Method to check.

RootBeer rootBeer = new RootBeer(context);
if (rootBeer.isRooted()) {
    //we found indication of root
} else {
    //we didn't find indication of root
}

2. Second Way For Implication with custom code.

In a second way you can write code for a check, the phone is rooted or not show you can just follow these simple step and write self code.

Add this method in our Activity class.

public static boolean findBinary(String binaryName) {
    boolean found = false;
    if (!found) {
        String[] places = { "/sbin/", "/system/bin/", "/system/xbin/",
                "/data/local/xbin/", "/data/local/bin/",
                "/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/" };
        for (String where : places) {
            if (new File(where + binaryName).exists()) {
                found = true;

                break;
            }
        }
    }
    return found;
}

private static boolean isRooted() {
    return findBinary("su");
}

And check in OnCreate phone is rooted or not with if and else like these.

if (isRooted()) {
//
//        } else {
//            ScreenControl();
//        }

 

Facebooktwitterredditpinterestlinkedinmail
Recommended
Hii in this Android solution we are sharing how to…