My device system is in English.
In my AndroidManifest.xml, I defined my activity to check configuration changes:
<activity
...
android:configChanges="locale" >
In my Activity, I add the function :
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Locale.setDefault(newConfig.locale);
Log.v("*Locale is*", newConfig.locale.toString());
getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
}
In my Activity onResume()
, I called the above function:
@Override
public void onResume() {
super.onResume();
// I explicitely force my app to display in Finnish
Configuration newConfig = new Configuration();
newConfig.locale = new Locale("fi");
onConfigurationChanged(newConfig);
}
(My Activity hosts fragments, Each screen view is a Fragment.)
With above code, I suppose my app will show in Finnish when launched. It works fine on Android 4.1.1.
But when I run my app on Android 2.3.3 device, the following thing happens:
Scenario 1: Launch the app from desktop ==> the app is showing in Finnish, No problem
Scenario 2: Login to my app, ==> then close the app ==> then, launch the app again from desktop ==> the app is showing in English!! Why???
(the log message Log.v("*Locale is*", newConfig.locale.toString());
shows me "fi" always!)
I verified that in Scenario 2, app always show the system default Locale when launch it again from desktop. Why?
I have no idea why in my Scenario 2, my app is showing in system locale English....any one could help?