I implemented a selective selection of locales about a year ago, but after the release of version 4.1, users begin to complain about the blinking of constant activity. Here is the code I'm using (compiled from different SO answers):
public final class TestApplication extends Application { private Locale desiredLocale = new Locale("ru-RU"); @Override public void onCreate() { super.onCreate(); updateLocale(new Configuration()); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); updateLocale(newConfig); } private void updateLocale(Configuration newConfig) { newConfig.locale = desiredLocale; Locale.setDefault(desiredLocale); getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics()); } }
The application contains only one empty activity, which is updated via Android every second after changing the orientation of the device. Here is the source of the sample.
It seems that all applications using this technique have become invalid. What is the right approach?
source share