I am investigating per app language in my current android application and have add this to my android manifest file
<code>android:configChanges="locale|layoutDirection"
</code>
<code>android:configChanges="locale|layoutDirection"
</code>
android:configChanges="locale|layoutDirection"
My activities onConfigurationChanged
function is called and I can see how to detect text direction changes using the below code:
<code>@RequiresApi(Build.VERSION_CODES.N)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (newConfig.layoutDirection == Configuration.SCREENLAYOUT_LAYOUTDIR_LTR) {
finishAffinity()
recreate()
}
}
</code>
<code>@RequiresApi(Build.VERSION_CODES.N)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (newConfig.layoutDirection == Configuration.SCREENLAYOUT_LAYOUTDIR_LTR) {
finishAffinity()
recreate()
}
}
</code>
@RequiresApi(Build.VERSION_CODES.N)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (newConfig.layoutDirection == Configuration.SCREENLAYOUT_LAYOUTDIR_LTR) {
finishAffinity()
recreate()
}
}
How do you detect the locale has changed?
Is by !newConfig.locales.isEmpty
?
1