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
wasyl
03/25/2020, 10:28 AM
So you want to have
onConfigurationChanged
get called in activity when configuration changed, but without recreating entire activity?
a
antoniomarin
03/25/2020, 10:33 AM
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
wasyl
03/25/2020, 12:04 PM
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
wasyl
03/25/2020, 12:05 PM
and instead the
onConfigurationChanged
callback will be called
a
antoniomarin
03/25/2020, 5:27 PM
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