1

I have a feeling I can deal with the above warning without forcibly suppressing it. However, this doesn't seems to work:

static Context updateResources(Context context) {
        Resources resources = context.getResources();
        Configuration config = new Configuration(resources.getConfiguration());
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String lang = preferences.getString(Constants.PREF_KEY_LOCALE_OVERRIDE, Constants.PREF_VALUE_LOCALE_SYSTEM);
        Locale locale = new Locale(lang);

        if (Build.VERSION.SDK_INT >= 17) {
            config.setLocale(locale);
            context = context.createConfigurationContext(config);
        } else {

        //this is where the warning is at: 
            config.locale = locale;
            resources.updateConfiguration(config, null);
        }
        return context;
}

How can I clear this warning?

warning: [deprecation] locale in Configuration has been deprecated

config.locale = locale;

PIXP
  • 2,382
  • 3
  • 19
  • 28

0 Answers0