0

My application supports for 2 languages- Spanish and English. When a user selects his preferred language from settings, the application changes to the user preferred language. It is working fine as expected. But recently encountered an issue where switching between some another installed application(In my case an app VUFORIA SPARK)application changing the behaviour of my application. I can sense that my locale is being overridden by this SPARK application. When my app is in Spanish >> switching to SPARk and back to my application changing the language to English.

Programmatically I am handling application using Locale configuration changes and setting language. Assuming this SPARK is somewhere setting their app to English is affecting my application. Can please anyone help me out how to not override my application configuration

public void setApplicationLanguage(Context context, String newLanguage) {
        Resources activityRes = context.getResources();
        Configuration activityConf = activityRes.getConfiguration();
        Locale newLocale = new Locale(newLanguage, 
        Locale.getDefault().getCountry());
        activityConf.setLocale(newLocale);
        activityRes.updateConfiguration(activityConf, 
        activityRes.getDisplayMetrics());
        Resources applicationRes = 
        context.getApplicationContext().getResources();
        Configuration applicationConf = applicationRes.getConfiguration();
        applicationConf.setLocale(newLocale);
        applicationRes.updateConfiguration(applicationConf,
                applicationRes.getDisplayMetrics());
    }

Thanks in advance

sudha
  • 193
  • 13
  • please try to set the language in splash screen and then try. Because at first the app doesnt know to open in which language. – Mohit patel Jun 18 '19 at 10:51
  • https://stackoverflow.com/questions/56057127/language-not-changing-in-app-android-studio/56057774#56057774 – Mayur Jun 18 '19 at 10:59

0 Answers0