Android12 -> configuration.setLayoutDirection(new Locale("ar")) not working

Viewed 88

It works on other android versions but below code doesn't work on android 12 devices. I use "ar" to language parameter.

val configuration: Configuration = resources.configuration
configuration.setLayoutDirection(Locale(language))
resources.updateConfiguration(configuration, resources.displayMetrics)
1 Answers

I had the same problem. Maybe a cache to recreate life cycle configuration, I use this:

val intent = activity.intent
activity.finish()
startActivity(intent)

It can take effect.

Related