0

I have a problem really similar to this one : Language change issue after updating to androidx.appcompat:appcompat:1.1.0 except that it is working great for me for Api 24 and below, but it doesn't work at all for Api 26 and above (couldn't test Api 25).

Gradle dependencies

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.2' //DO NOT UPGRADE - Translation issue
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    testImplementation 'androidx.test:core:1.2.0'
    testImplementation 'androidx.test.ext:junit:1.1.1'
    implementation 'com.google.android.material:material:1.0.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
}

Code triggered when I click on a button

 /**
     * Select language application
     */
    public static void defineLanguage(ImageButton button, final String value, final Activity activity, final Activity source) {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Locale locale = new Locale(value);
                Locale.setDefault(locale);
                Configuration config = new Configuration();
                config.locale = locale;
                activity.getApplicationContext().getResources().updateConfiguration(config, 
    activity.getBaseContext().getResources().getDisplayMetrics());

                Intent intent = new Intent(activity, source.getClass());
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                activity.finish();
                activity.startActivity(intent);
            }
        });
    }

Should I also wait for a fix from Google or is my problem slightly different?

Lena
  • 511
  • 1
  • 4
  • 19
  • 1
    Check this https://stackoverflow.com/a/58109994/7666442 – AskNilesh Oct 10 '19 at 08:52
  • Thanks to your comment I followed this https://stackoverflow.com/questions/52187959/resources-and-layout-direction-rendered-incorrectly-only-on-android-8-0-and-abov/52270630#52270630 and it works perfectly. Thank you for your help! – Lena Oct 10 '19 at 09:33

0 Answers0