Root权限下修改 Android 系统时间

xiaoxiao2021-02-28  121

权限为 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; }
转载请注明原文地址: https://www.6miu.com/read-29505.html

最新回复(0)