第一步
app工程的清单文件application内设置
<application
android:localeConfig="@xml/locales_config">
locales_config.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- https://developer.android.google.cn/about/versions/13/features/app-languages?hl=zh-cn#use-localeconfig -->
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="zh-CN" />
<locale android:name="zh-TW" />
<locale android:name="en" />
</locale-config>
第二步打开系统语种选择器
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Intent intent = new Intent(Settings.ACTION_APP_LOCALE_SETTINGS);
intent.setData(Uri.parse("package:" + sApplication.getPackageName()));
if (LanguagesUtils.areActivityIntent(sApplication, intent)) {
return intent;
}
}