欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android手機(jī)獲取root權(quán)限并實(shí)現(xiàn)關(guān)機(jī)重啟功能的方法

 更新時(shí)間:2014年08月20日 15:37:25   投稿:shichen2014  
這篇文章主要介紹了Android手機(jī)獲取root權(quán)限并實(shí)現(xiàn)關(guān)機(jī)重啟功能的方法,是Android程序設(shè)計(jì)中非常重要的技巧,需要的朋友可以參考下

本文實(shí)例講述了Android手機(jī)獲取root權(quán)限并實(shí)現(xiàn)關(guān)機(jī)重啟功能的方法,是Android程序設(shè)計(jì)中非常常見的重要功能?,F(xiàn)分享給大家,供大家在Android程序開發(fā)中參考之用。

具體功能代碼如下:

/*
 * 執(zhí)行命令
 * @param command
 * 1、獲取root權(quán)限 "chmod 777 "+getPackageCodePath()
 * 2、關(guān)機(jī) reboot -p
 * 3、重啟 reboot
 */
public static boolean execCmd(String command) {
 Process process = null;
 DataOutputStream os = null;
 try {
 process = Runtime.getRuntime().exec("su");
 os = new DataOutputStream(process.getOutputStream());
 os.writeBytes(command+"\n");
 os.writeBytes("exit\n");
 os.flush();
 process.waitFor();
 } catch (Exception e) {
  return false;
 } finally {
  try {
  if (os != null) {
   os.close();
  }
  if(process != null) {
   process.destroy();
  }
  } catch (Exception e) {
  e.printStackTrace();
  }
 }
 return true;
}

希望本文所述實(shí)例對(duì)大家的Android程序設(shè)計(jì)起到一定的幫助作用。

相關(guān)文章

最新評(píng)論