Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onConfigurationChange not called after changing locale

I have to refresh the fragments contents on change of language from one fragment. So I thought of using onConfigurationChange method which is in my Main activity (this activity controls all the fragments) and recreate all the fragments on change of locale. But this method is not being called on change of locale.

I have included locale under the activity tag of manifest file. onConfigurationChange is being called on change of orientation.

i am changing language as given in this link Change language programmatically in Android and its working.

Can someone please clarify what change would be required to fix this issue.

like image 762
user2702700 Avatar asked Sep 10 '13 17:09

user2702700


Video Answer


1 Answers

For others who encounter this issue the OP was right but a bit unclear.
You have to define android:configChanges="layoutDirection|locale" in order for onConfigurationChanged() to be called.
I assume that this is necessary because locale change might also affect layout direction (for RTL languages) so declaring just locale might not be enough, yet this is only my assumption on this matter.

like image 186
Alex.F Avatar answered Sep 28 '22 02:09

Alex.F