Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization is not working in Lollipop

I am developing an app which is to be opened directly in Portuguese language and inside that app it has having the option of changing the language to English. So i have to change the language in the code . But when i tested my app in Lollipop, it is directly opening in English Language. In all other versions except the lollipop , it is working fine. Can some one help me or suggest me the steps which i have to take to solve this bug. Thanks

Here is the code which i am using for the localization. Have some methods been "depreciated" from lollipop?

    public static Locale locale = new Locale("pt_BR");
    Locale.setDefault(locale);
    android.content.res.Configuration config = new android.content.res.Configuration();
    config.locale = locale;
    this.getResources().updateConfiguration(config, null);
    String locale = this.getResources().getConfiguration().locale
            .getDisplayName();
    Log.i("System out", "(LogIn)Current Language : " + locale);
like image 241
Gaurang Avatar asked Feb 02 '15 04:02

Gaurang


People also ask

How do I change localization in Android?

You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”. Click Add language and add a fallback language.

How does localization work in Android?

In order to localize the strings used in your application , make a new folder under res with name of values-local where local would be the replaced with the region. Once that folder is made, copy the strings. xmlfrom default folder to the folder you have created. And change its contents.


1 Answers

Due to some security issue --> java.lang.SecurityException: Permission Denial:

Language changing is not working, please try to change
Locale locale = Locale("en_US");
to
Locale locale = Locale("en", "US"); //Locale locale = Locale("language", "Country")

like image 101
Bhavana Vadodariya Avatar answered Sep 29 '22 13:09

Bhavana Vadodariya