This is in the super-class. My Activities extends from it and call super.onCreate at first. After this call, they set their layout and initializes their settings...

I thought that my lines of code would make it. But I have the following problem: Sometimes, the activity changes the language and sometimes not!

If I set a debug breakpoint on it and after the programm pauses I press continue, everything works fine. So I think, in some cases, where my Application is "slow enough", the language will change correctly, whereas the language won't change if the application is too fast...

Is there any solution of my problem? How can I be sure, that my language will change correctly in any time?

Thanks a lot!

Edit: Here is an example for a class which extends from my super-class

2 Answers
2

changeLanguage(this); only needs to be called when the language has changed or when the App is loaded.. res.updateConfiguration(conf, dm); updates the global config and is specific to your app instance not your activity instance.

When you change the locale in an Activity you have to recreate that Activity to see your language change. This can be easily done by forcing an orientation change then forcing it back like this:

If you hit back after a language change you will see the old language because onCreate is not called. You will have to detect in onResume that the language changed and force a recreate of the Activity.

-= EDIT =-

Using Screen Orientation to reload the Activity has proven to be a bit buggy on some devices. I am now using this to reload the current Activity:

I think you need to post an example of an Activity that extends your superclass. Calling changeLanguage in onCreate() seems suspicious to me, though. That's only going to run when the app is first initialized. To change the language once your app is loaded, you'd have to stop it and re-create it.

Hey. I've added an example. Its just call the onCreate and set the content-view. Sometimes it works, sometimes it didn't. When i set a breakpoint at setContentView and continue it'll works definitely
–
Frame91Apr 18 '13 at 18:27