Root权限下修改 Android 系统时间

来源:互联网 发布:想搞网络课直播 编辑:程序博客网 时间:2024/05/24 20:07

权限为 Root 权限

    /**      * 设置系统时间      * @param time 格式为“年月日.时分秒”,例如:20111209.121212      */      public static boolean setTime(String time) {          Process process = null;          DataOutputStream os = null;          try {              process = Runtime.getRuntime().exec("su");              os = new DataOutputStream(process.getOutputStream());              os.writeBytes("date -s " + time + "\n");              os.writeBytes("exit\n");              os.flush();              process.waitFor();          } catch (Exception e) {              return false;          } finally {              try {                  if (os != null) {                      os.close();                  }                  process.destroy();              } catch (Exception e) {              }          }          return true;      }  
原创粉丝点击