2

I want to change my app language , this is a code I've for supporting different api versions

val config: Configuration = context.getResources().getConfiguration()
    val locale = Locale(getDefaultLang())
    val res: Resources = context.getResources()
    if (Build.VERSION.SDK_INT >= 17) {
        config.setLocale(locale)
    } else {
        config.locale = locale
    }
    val dm = res.displayMetrics
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        context.createConfigurationContext(config);
    } else {
        context.getResources().updateConfiguration(config,dm);
    }

the problem is , on api 23 and above , it goes into this line :

context.createConfigurationContext(config);

but it doesn't effect the app and I should use this line to make it works

res.updateConfiguration(config, dm)

as you know , update configuration is depreciated

how to fix this ?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Navid Abutorab
  • 1,667
  • 7
  • 31
  • 58

0 Answers0