How to set default stings.xml using AppCompatDelegate in android?

24 Views Asked by At

AppCompatDelegate is a new way to change application's locale according to user's preferred language which can be done as follow:

AppCompatDelegate.setApplicationLocales(
   LocaleListCompat.forLanguageTags(userSelectedLocaleTag)
)

My problem with this delegate is that when device's default language is any language other than English, I cannot force the app to use default strings.xml.

I tried to use below code in Application class but it does not work (I do not have english strings.xml file. I just have default xml for english):

AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("en"))

I tested this on Android SDK 33

0

There are 0 best solutions below