/*********修改系统语言,不需要重启**********/
public static void setLanguage(Locale locale) {
try {
Object objIActMag;
Class clzIActMag = Class.forName("android.app.IActivityManager");
Class clzActMagNative = Class
.forName("android.app.ActivityManagerNative");
Method mtdActMagNative$getDefault = clzActMagNative
.getDeclaredMethod("getDefault");
objIActMag = mtdActMagNative$getDefault.invoke(clzActMagNative);
Method mtdIActMag$getConfiguration = clzIActMag
.getDeclaredMethod("getConfiguration");
Configuration config = (Configuration) mtdIActMag$getConfiguration
.invoke(objIActMag);
config.locale = locale;
Class clzConfig = Class
.forName("android.content.res.Configuration");
java.lang.reflect.Field userSetLocale = clzConfig
.getField("userSetLocale");
userSetLocale.set(config, true);
Class[] clzParams = { Configuration.class };
Method mtdIActMag$updateConfiguration = clzIActMag
.getDeclaredMethod("updateConfiguration", clzParams);
mtdIActMag$updateConfiguration.invoke(objIActMag, config);
BackupManager.dataChanged("com.android.providers.settings");
} catch (Exception e) {
e.printStackTrace();
}
}
/********获取和修改NTF服务*********/
private String getNTPServer() {
return Settings.Global.getString(getContentResolver(),Settings.Global.NTP_SERVER);
}
Settings.Global.putString(getContentResolver(),Settings.Global.NTP_SERVER,sci.getNtp_server());
网友评论