Устранение устаревших предупреждений lint без использования @SuppressWarnings - PullRequest
0 голосов
/ 05 сентября 2018

У меня такое чувство, что я могу справиться с приведенным выше предупреждением, не подавляя его принудительно. Тем не менее, это не похоже на работу:

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;
}

Как я могу снять это предупреждение?

предупреждение: [устарел] языковой стандарт в конфигурации устарел

config.locale = locale;

...