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 ?

1
  • 2
    Hi Navid, did you find a solution for this? Commented Nov 21, 2020 at 23:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.