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?