Search code examples
androidlocalizationandroid-5.0-lollipop

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);

Solution

  • 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")