1

i'm in my app, one activity is opened. I press home button and change language, from taskmanager opens my app. Problem: my activity layout is getting wide.

changes in androidmanifest corresponding to that activity:

Note: If i add locale in android manifest, layout is proper, but language is not getting updated immediately. User have to close that activity and then restart, only then language is getting updated.

Please provide me your inputs.

Mansfield
  • 14,445
  • 18
  • 76
  • 112
parul
  • 363
  • 1
  • 6
  • 16
  • That's the normal behavior. When you start your application, your device says "Hey! I'm using that Locale so please provide the right resources...". Then, when you change Local while your application is already started, it's too late because the right resources have already been loaded. So you HAVE to reload. – Jeje Doudou May 25 '12 at 08:44
  • Do i need to add locale attribute also in android manifest? – parul May 25 '12 at 08:56
  • Absolutely not. By default, the used local is your device's one. – Jeje Doudou May 25 '12 at 09:07

1 Answers1

3

As mentioned in the comment on your question, it is normal behaviour.

A change in Locale is considered a change of Configuration the same as a change in orientation etc.

You need to override onConfigurationChanged in your Activity and reload everything from there.

NOTE: You will also need to specify android:configChanges="locale" in the Activity declaration in the AndroidManifest file.

Squonk
  • 48,735
  • 19
  • 103
  • 135
  • 1
    I have some problem i tried to overide onConfigurationChanged but it isn't called in Fragment Activity when i change locale – Streetboy May 25 '12 at 11:22
  • 1
    I am also facing the same issue. Arabic and English languages are using in my app. When changing the language to Arabic then, it shows arabic strings in activity pages but it show still english in fragmet pages. – Arun PK Jul 31 '19 at 09:23