1

I have the below codde that i am tring to update the androis language

Resources res = context.getResources();
// Change locale settings in the app.
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.setLocale(new Locale(language_code.toLowerCase())); // API 17+ only.
// Use conf.locale = new Locale(...) if targeting lower versions
res.updateConfiguration(conf, dm);

But seem not to be working as the language is not changing. what can be the problem?

lewis machilika
  • 819
  • 2
  • 11
  • 25
  • https://stackoverflow.com/questions/2900023/change-app-language-programmatically-in-android Try this one... There has been some updates in 2021 – Abraham Mathew Dec 07 '21 at 05:01

1 Answers1

0

Use this line of code conf.setLayoutDirection(new Locale(language_code.toLowerCase())); Here is source code of change language in app it will help you.

Note

this method is useful on your debugging apk and signed .apk but it is not working on the bundle file because Google also split bundle files on the basis of language. and you should enableSplit = false in build.gradle

 bundle {
        language {
            // Specifies that the app bundle should not support
            // configuration APKs for language resources. These
            // resources are instead packaged with each base and
            // dynamic feature APK.
            enableSplit = false
        }
    }
Yaqoob Bhatti
  • 1,271
  • 3
  • 14
  • 30