I need to know what locale a user is located in for legal reasons. We've settled on using the users' system locale as the way to get the users' locations. The problem I have is that with Android 13+ per-app locale, if a user's system is set to a local that is not list in my app's resourceConfigurations
then Locale.getDefault()
will return a locale that is listed in resourceConfigurations
even if the user has not explicitly set a different per-app locale from the system locale.
I need a way to see the system locale regardless of the locale the system has set for my app.
If I remove resourceConfigurations
from the app's build.gradle
then the problem I'm having is fixed, however, then the system (understandably) doesn't show the correct languages in the system per-app language picker.
Resources.getSystem().getConfiguration().locale
and Resources.getSystem().getConfiguration().getLocales().get(0)
both return the same as Locale.getDefault()
If you need to know for legal reasons, do NOT use locale. It has no relationship to the place the user is in or the laws they follow. It relates to their preferred language. For example a US ex-pat living in Europe will still have their phone set to en. You don't even know if it will be set to en-us, or en-uk because they bought it in europe and that's the default for en on that model. It's not going to be right enough to use for anything that needs to be done for legal purposes.