To ensure your app's languages are configurable in system settings on devices running Android 13 or higher, we need to create a locales_config
XML file and add it our app's manifest using the android:localeConfig
attribute (see here).
For example, locales_config.xml
might contain:
<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en"/>
<locale android:name="en-GB"/>
<locale android:name="fr"/>
<locale android:name="ja"/>
<locale android:name="zh-Hans-MO"/>
<locale android:name="zh-Hant-MO"/>
</locale-config>
If we also want to provide a custom locale picker in our app's settings, how do we retrieve the list of supported locales from locales_config.xml
in order to populate our picker (without duplicating the list in the locale picker code)?
Context
, callgetResources().getXml(R.xml.locales_config)
to get anXmlResourceParser
on the contents of your XML resource. – Ottinger