权限为 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;
}
848




被折叠的 条评论
为什么被折叠?



