Android 台灣中文網

標題: 應用程序獲取權限(手機須root) [打印本頁]

作者: lkk47    時間: 2011-10-31 15:59
標題: 應用程序獲取權限(手機須root)
  1. public static boolean runRootCommand(String command) {
  2.         Process process = null;
  3.         DataOutputStream os = null;
  4.         try {
  5.             process = Runtime.getRuntime().exec("su");
  6.             os = new DataOutputStream(process.getOutputStream());
  7.             os.writeBytes(command+"\n");
  8.             os.writeBytes("exit\n");
  9.             os.flush();
  10.             process.waitFor();
  11.         } catch (Exception e) {
  12.                 Log.d(TAG, "the device is not rooted, error message: " + e.getMessage());
  13.                 return false;
  14.         } finally {
  15.             try {
  16.                 if (os != null) {
  17.                     os.close();
  18.                 }
  19.                 if(process != null) {
  20.                     process.destroy();
  21.                 }
  22.             } catch (Exception e) {
  23.                 e.printStackTrace();
  24.             }
  25.         }
  26.         return true;
  27.     }
複製代碼
這是轉載的不知道圖片也能不能一起轉載
如果不清楚可至轉載網站查詢
轉載於:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=65892

作者: ploglin    時間: 2011-11-1 08:58
看起來就是在下command前,先下 su 的 command,受教了。
作者: lobos    時間: 2011-11-7 03:11
看不懂ㄝ...
作者: king80301    時間: 2012-2-14 06:57
這是啥?????




作者: kanojerry    時間: 2012-2-26 19:47
謝謝提供,正在找ROOT的程式碼




歡迎光臨 Android 台灣中文網 (https://apk.tw/) Powered by Discuz! X3.1