Heya, one Android specific question. Is there any ...
# android
a
Heya, one Android specific question. Is there any way to manually tigger
onConfigurationChanged
? I’m dealing with the locales, and when I do update it manually I need to somehow
recreate
the views, recreating activity will kick user out and he will need to re-log so I would rather try to avoid that. I’m also trying with the following but it doesn’t work completely which is weird in fairness:
Copy code
val res = resources
val configuration = res.configuration
configuration.setLocale(Locale(preferences.userLocale))
onConfigurationChanged(configuration)
w
So you want to have
onConfigurationChanged
get called in activity when configuration changed, but without recreating entire activity?
a
Well I want to replicate what happens when you do
configurationChanges
. For example. I’m gonna setup new Locale and then enter split screen mode and upon exiting it my Locale changes will be reflected on the app. Activity won’t restart.
w
Not sure if it helps, but you set
android:configChanges
attribute in the manifest, then for configuration changes enumerated there, activity won’t restart
👍 1
and instead the
onConfigurationChanged
callback will be called
a
I’m doing this at the moment:
Copy code
var orientation1: Int = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
var orientation: Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                    requestedOrientation = orientation1                    requestedOrientation = orientation
It does auto rotate and that way it does
onConfigurationChange