Search code examples
androidlocale

Do we need to force locale or is it forced by default?


Let's say we are making a calculator/game app for Android that does not contain any text other than digits: "1,2,3,4..." ...and we develop the app in the default "en_US" format... and we do not explicitly make any provisions, settings, or choices for alternate locales.

If the user has their global phone settings set to some Locale that formats numbers differently, perhaps using an entirely different script...

Will their settings override the app and potentially distort the layout?

and if so, is there any way to force the locale of the app to "en_US"?


Solution

  • If you use string resources and load them with something like getString(R.string.my_string), then your app will use the devices current locale setting and attempt to find a string resource file that matches. If there is none, then the default string resource file will be used. This means that you only have to provide a single strings.xml file and it will be used no matter which locale is set on the device.

    If you are using int values in your Java code, then they will be used as-is. No localization will be applied.