1,设置系统时间和日期需要系统签名权限,apk的签名需要是系统级别的,否则设置不了。
即在项目的AndroidManifest.xml文件的manifest节点中加入:android:sharedUserId="android.uid.system"这个属性。
- /**
- * the app must have system permission
- * */
- public static void setSystemTime(final String dateString){
-
- if (PackageUtil.isSystemApp(MyApplication.sContext)) {
- LogUtil.i("THIS APP IS SYSTEM APP!");
- try {
- long curTime = uitlTool.getStringToDate(dateString, pattern);
-
- SystemClock.setCurrentTimeMillis(curTime);
- SystemClock.uptimeMillis();
- }catch (Exception e){
- LogUtil.e("error = "+e.getMessage());
- }
- }else{
- LogUtil.i("THIS APP IS NOT SYSTEM APP!");
- }
- }
只要拥有的系统签名权限,安装了应用后,才能修改系统的权限!