2

It happens that my app sometimes changes language in runtime by itself. Did anyone encounter this problem? This is the function which I use to set language manually (when user selects it in my app):

public static void setSystemLanguage(Context context, Configuration configuration, String language) {
        configuration.locale = new Locale(language);
        context.getResources().updateConfiguration(configuration, context.getResources().getDisplayMetrics());
    }

I really don't have more information, I'm unable to reproduce it. This doesn't happen very often, but few users complained about it. The only thing I know is that suddenly when user opens new activity, it is opened with different language. And this doesn't happen on some specific activity, every time user post problem, it was different activity.

I allow users to choose language when they install the app. Users can set language which is different than the one which is on their devices. I believe that app changes the language by itself to the system language (not the random one).

Ban Markovic
  • 690
  • 1
  • 7
  • 12
  • 1
    Add more details, how does it change itself? What things are executed that may lead to this behavior? – Taseer Aug 02 '19 at 13:02
  • I really don't have more information, I'm unable to reproduce it. This doesn't happen very often, but few users complained about it. The only thing I know is that suddenly when user opens new activity, it is opened with different language. And this doesn't happen on some specific activity, every time user post problem, it was different activity. – Ban Markovic Aug 02 '19 at 13:11
  • 1
    Try this one https://stackoverflow.com/a/48531811 i have used similar solution and everything works great – Ikazuchi Aug 02 '19 at 13:25
  • So this suggests that I should set language on every activity? I mean, make BaseActivity which will be extended by every Activity inside my app, and in attachBaseContext method, call setSystemLanguage? – Ban Markovic Aug 02 '19 at 13:44
  • why do you set the language manually? – Tim Aug 02 '19 at 13:54
  • 2
    There is some information you can add to help people answer your question: 1) When do you call the function you posted here in your code? 2) From what language to what language does the app change? 3) Do you let the user select a language for your app that is different from the system language? 4) Does the app go back to the system language some times? 5) Does it go to random language? – Lev M. Aug 02 '19 at 14:11

0 Answers0