Android just introduced Per-app language preferences in Android API level 33 which let you change the app language regardless of the system language.
To support devices that running API <= 32, Android in Androidx Appcompat: androidx.appcompat:appcompat:1.6.0-beta01
has added: AppCompatDelegate.setApplicationLocales(appLocale);
Now app language can be differ from system language.
Now there are 2 scenarios:
- In API <= 32:
Locale.getDefault()
will return the system Locale which is equal to the app. - In In API 33:
Locale.getDefault()
will return the app locale not the system. And to get system locale,LocaleManagerCompat.getSystemLocales(this).get(0)
can be used.
My question: How to get App locale in Android API <= 32 When using backward compatibility with out the need to use Context
?
I have found this which is the opposite to what I need.
What I have tried to store Locale then fetch it whenever needed but this method needs Context
which is incompetent.
AppCompatDelegate.getApplicationLocales()
is returning a list, maybe you are using only 1 locale. SoAppCompatDelegate.getApplicationLocales().get(0)
is the way to get the the App locale. – Midshipmite