當前位置:編程學習大全網 - 網站源碼 - Android怎麽判斷當前應用是否有root權限?

Android怎麽判斷當前應用是否有root權限?

AndroidAndroid 代碼判斷是否獲取ROOT權限

方法比較簡單,直接粘貼代碼

public 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();

}

}

}

  • 上一篇:唐山網站制作源代碼
  • 下一篇:獨家全球代理ip是什麽意思?
  • copyright 2024編程學習大全網