如何检查Android手机是否已植根?

Key*_*eya 8 android root

我想在我的应用程序中以编程方式查找Android手机是否已植根.我找到了许多链接:确定是否在root设备上运行 有效的方式以编程方式检查我是否植根于Android?讨论同一主题.然而,正如那些链接所提到的,没有一个明确的方法可以找到答案.这些帖子很老了,我想知道在最近的版本中是否有更好的方法可以实现它?

提前致谢!

StE*_*rMi 20

我从RootTools中包装了这段代码(没有任何其他外部jar/lib工作正常)

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



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;
}
Run Code Online (Sandbox Code Playgroud)

  • @MatF你可以看到我在答案中已经说过了.我从RootTools中包装了那段代码...... (9认同)

Mat*_*atF 5

您可以使用roottools库.它们提供了一种检查root访问权限的方法. https://code.google.com/p/roottools/