Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale gets reverted to device's default, after some time in the background (target 25) #382

Open
dor506 opened this issue Apr 20, 2017 · 0 comments

Comments

@dor506
Copy link

dor506 commented Apr 20, 2017

Hi

We just updated our app configuration to target and compile against api 25.

The app is using multiple languages, so we set the locale in the configuration according to user selection.

We have a base activity that implements the context wrapping:

@Override
protected void attachBaseContext(Context newBase)
{
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

We found the following problem:

  1. We run the application when the device locale is en_US. (in this stage the application locale is en_US)
  2. We update the configuration (locale) of the app in the application onCreate method:
    Locale locale = new Locale("iw"); // hebrew for example
    Locale.setDefault(locale);
    android.content.res.Configuration config = new android.content.res.Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
    getBaseContext().getResources().getDisplayMetrics());

(in this stage the application locale is iw_IL)
3. We go to the background, and after some time, when going to foreground, we discover that the application locale is reverted back to en_US.

** We didn't find the exact cause for this issue, But A quick way to reproduce this is while in background, to rotate the device to landscape and then to portrait, and then go back to our application. it happens immediately.

If you need more details, we'd love to supply.

Thanks in advance!

@dor506 dor506 changed the title Locale gets reverted to default after some time in the background (target 25) Locale gets reverted to device's default, after some time in the background (target 25) Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant