Home » Android » android – Localization is not working in Lollipop

android – Localization is not working in Lollipop

Posted by: admin June 15, 2020 Leave a comment


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.

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");
    android.content.res.Configuration config = new android.content.res.Configuration();
    config.locale = locale;
    this.getResources().updateConfiguration(config, null);
    String locale = this.getResources().getConfiguration().locale
    Log.i("System out", "(LogIn)Current Language : " + locale);
How to&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”);
Locale locale = Locale(“en”, “US”); //Locale locale = Locale(“language”, “Country”)