安卓开发 用应用程序修改系统时间

和http://blog.csdn.net/cx5615033/article/details/13019361一样,因为那个博客也是我的

1、自己的源码可以用签名的方法修改,这个网上一查一大片。

2、修改已经ROOT过的手机可以这样:

public void testDate(){
try {
Process process = Runtime.getRuntime().exec("su");
String datetime="20131023.112800"; 
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("setprop persist.sys.timezone GMT\n");//时区,会在设置时间的基础上+8小时
os.writeBytes("/system/bin/date -s "+datetime+"\n");
os.writeBytes("clock -w\n");
os.writeBytes("exit\n");
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
}

猜你喜欢

转载自blog.csdn.net/qq_28714343/article/details/51985225