Stylianos Gakis
08/26/2022, 2:40 PMsetApplicationLocales()
recreates your Activity
, unless your app handles locale configuration changes by itself.”
Now I remember reading some discussions here, like this one where @Adam Powell suggests that compose handles those itself anyway.
Shouldn’t that mean that the documentation should reflect this behavior if it’s also the case for this config change too? It’d be great to know that directly from there without needing to be part of this slack channel.Michael Paus
08/26/2022, 2:49 PMStylianos Gakis
08/26/2022, 2:56 PMconfigChanges
right?
If it’s not only compose, does it work if the root is a composable but maybe you have some AndroidViewBinding
in the middle? Does it work if the root is a XML layout but some children are composables? Do maybe only the composable parts of it get invalidated? Hmm not sure tbhMichael Paus
08/26/2022, 3:09 PMStylianos Gakis
08/26/2022, 3:14 PMAdam Powell
08/26/2022, 3:45 PMAdam Powell
08/26/2022, 3:46 PMAlex Vanyo
08/26/2022, 4:43 PMLocale.getDefault()
(or a built-in method that uses it under the hood), then that use of the locale isn’t snapshot-state aware, so it won’t necessarily get updated. Or for a custom View
, you’d need to listen to View.onConfigurationChanged
to update yourself.
With activity recreation, you could usually use Locale.getDefault()
and be just fine because you’d end up calling it again as everything was reconstructed.
Activity recreation is the original “reemit the UI when something changes”Stylianos Gakis
08/26/2022, 5:02 PMconfigChanges
tbh still.Adam Powell
08/26/2022, 5:08 PMMichael Paus
08/26/2022, 5:27 PMAdam Powell
08/26/2022, 5:31 PMStylianos Gakis
08/26/2022, 5:36 PMAdam Powell
08/26/2022, 8:46 PMLocalConfiguration.current.locale
instead of Locale.getDefault()
Alex Vanyo
08/26/2022, 9:38 PMConfigurationCompat.getLocales(LocalConfiguration.current)[0]
is the compat one that won’t complain about being deprecated)Adam Powell
08/26/2022, 9:39 PMZoltan Demant
08/27/2022, 5:23 AMcontext.getString
, but I control that context and its locale (upading to match the Android 13 changes)? Or are there any other cases where LocalConfiguration.current.locale is used besides for fetching strings?Michael Paus
08/27/2022, 8:49 AMZoltan Demant
08/27/2022, 11:11 AMMichael Paus
08/27/2022, 12:08 PM