您现在的位置是:首页 > 文章详情

Android--手机root获取与判断应用是否获取

日期:2018-07-16点击:297
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/81075850
import android.util.Log; import java.io.DataOutputStream; import java.io.File; /** * 判断手机是否ROOT */ public class isRoot{ public static int root() { int root = 0; try { if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())) { root = 0; } else { root = 1; } } catch (Exception e) { } return root; } /** * * 判断应用是否有root权限 */ public static synchronized boolean getRootAhth() { Process process = null; DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes("exit\n"); os.flush(); int exitValue = process.waitFor(); if (exitValue == 0) { return true; } else { return false; } } catch (Exception e) { Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: " + e.getMessage()); return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { e.printStackTrace(); } } } } 

 

原文链接:https://yq.aliyun.com/articles/631436
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章