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

Per-app Language Preferences Sample screen flash and android:configChanges problem #481

Open
winstonsung opened this issue Feb 7, 2025 · 1 comment

Comments

@winstonsung
Copy link

winstonsung commented Feb 7, 2025

Steps to reproduce:

Without layoutDirection|locale|screenLayout added to android:configChanges

  • Testing in API 35
    • Works as expected: UI stringResource strings did change when switching language
    • Unexpected: screen flashes (completely black screen before showing changed UI string)
  • Testing in API 31 & API 24
    • Works as expected: UI stringResource strings did change when switching language
    • Works as expected: screen won't flash

With layoutDirection|locale|screenLayout added to android:configChanges

To fix the screen flash problem during language switching, I tried to add layoutDirection|locale to android:configChanges to <activity>

  • Testing in API 35
    • Works as expected: UI stringResource (string changed when switching language)
    • Works as expected: screen won't flash again
  • Testing in API 31 & API 24
    • Unexpected: UI stringResource strings didn't change when switching language (only the current language label of the language dropdown changed)
      • Testing in another application with AnimatedVisibility used: the string only changed to the switched language when they change their visibility
    • Works as expected: screen won't flash

Additional information

There are several articles mentioned attachBaseContext and onConfigurationChanged, but I couldn't find any up-to-date solution.

@jmartinMone
Copy link

Same problem here.
stringResource is not updated correctly from api 24 to 33 when config change triggered (LocalConfiguration.current not updated...)

To manage configChanges, you must also add screenLayout to avoid black screen (screen flashes)
So, you should haveandroid:configChanges="locale|layoutDirection|screenLayout"

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

2 participants