Abstract
This document is describing how to solve problem with changing language of application on
Android Nougat
Edin Selimovi
1. Creating class
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static ContextWrapper wrap(Context context) {
configuration.setLocale(newLocale);
context = context.createConfigurationContext(configuration);
configuration.setLocale(newLocale);
configuration.locale = newLocale;
res.updateConfiguration(configuration, res.getDisplayMetrics());
context = context.createConfigurationContext(configuration);
2. Usage of class
The second step is to use class Android7LocaleWrapper.java in your code in the next way:
@Override
protected void attachBaseContext(Context newBase) {
Context context = Android7LocaleWrapper.wrap(newBase);
super.attachBaseContext(context);
}