Search code examples
androidlocaleorientation

Android - Forced locale reset on orientation changes


I try to force the locale in my app to one the user specified. As this may be used to demonstrations, I want to change the language/locale in the app and not anytime for the whole device.

I looked around SO and tried to use every hint I found here. The result: I can restart my test activity with the new language, but if I change the orientation, the locale will always be reseted to the device one.

I uploaded a minimalistic project so you can reproduce my issue. Please ignore the shrinking of the UI, it's not important :)


Solution

  • Is the reset of the locale occurring because your Activity is being restarted on orientation change?

    If so, you can intercept or prevent orientation changes: Activity restart on rotation Android