Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App language (Locale) automatically gets reset to default after opening camera to capture a photo or gallery to select image

Tags:

java

android

We have a setLocale function as following:

 public static void setLocale(Context context, String locale) {
            Locale myLocale = new Locale(locale);
            Resources res = context.getResources();
            DisplayMetrics dm = res.getDisplayMetrics();
            Configuration conf = res.getConfiguration();
            conf.locale = myLocale;
            res.updateConfiguration(conf, dm);
        }

We use above method as follows:

sessionManager.setAppLanguage(locale, this);
setLocale(context,sessionManager.getAppLanguage(this));                       

We are using following locales:

English = "en";
        Hindi = "hi";
        Marathi = "ma";

But everytime when we open a camera, capture a photo, some labels get reset to default language and some labels remain in selected language. This happens in case of selecting photo from gallery also.

Note: Issue is device specific. Now we are seeing in Samsung star pro (KITKAT 4.1) and Sony Xperia E3 dual (KITKAT 4.4.4)

like image 455
Vrushali Sabnis Avatar asked Oct 27 '25 08:10

Vrushali Sabnis


1 Answers

It might happen that you are calling the setLocale method in your Activity initialization, such as in onCreate method. You might want to call it in onActivityResult also.

like image 172
jaibatrik Avatar answered Oct 28 '25 21:10

jaibatrik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!