1. 程式人生 > >android 7.1系統語言設定和5.1.1不同

android 7.1系統語言設定和5.1.1不同

//7.1參考 \frameworks\base\core\java\com\android\internal\app\LocalePicker.java
public static void updateLocale(Locale locale) {
updateLocales(new LocaleList(locale));
}
   /**
     * Requests the system to update the list of system locales.
     * Note that the system looks halted for a while during the Locale migration,
     * so the caller need to take care of it.
     */
    public static void updateLocales(LocaleList locales) {
        try {
            final IActivityManager am = ActivityManagerNative.getDefault();
            final Configuration config = am.getConfiguration();


            config.setLocales(locales);
            config.userSetLocale = true;


            am.updatePersistentConfiguration(config);
            // Trigger the dirty bit for the Settings Provider.
            BackupManager.dataChanged("com.android.providers.settings");
        } catch (RemoteException e) {
            // Intentionally left blank
        }

    }

5.11的方式 \frameworks\base\core\java\com\android\internal\app\LocalePicker.java
    public static void updateLocale(Locale locale) {
        try {
            IActivityManager am = ActivityManagerNative.getDefault();
            Configuration config = am.getConfiguration();


            // Will set userSetLocale to indicate this isn't some passing default - the user
            // wants this remembered
            config.setLocale(locale);


            am.updateConfiguration(config);
            // Trigger the dirty bit for the Settings Provider.
            BackupManager.dataChanged("com.android.providers.settings");
        } catch (RemoteException e) {
            // Intentionally left blank
        }
    }