Android 添加语言目录的函数:frameworks/base/core/java/com/android/internal/app/LocalePicker.java
根据以上方法分析.语言配置文件保存在R.arry.supported_locales
根据查找该配置文件在:frameworks\base\core\res\res\values\locale_config.xml
删除或者注释掉多余的语言配置 既可实现仅保留中文和英文
定制接口修改系统默认语言:
public void updateLocale(Locale locale) { try { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); config.setLocale(locale); config.userSetLocale = true; am.updateConfiguration(config); // Trigger the dirty bit for the Settings Provider. BackupManager.dataChanged("com.android.providers.settings"); } catch (RemoteException e) { // Intentionally left blank } }
配置开机默认语言:
build/make/target/product/full_base.mk
build/make/target/product/languages_default.mk
在full_base.mk文件中修改默认中文
# Put en_US first in the list, so make it default.
+PRODUCT_LOCALES := zh_CN en_US
在/languages_default.mk文件中修改默认中文# This is a build configuration that just contains a list of languages, with
# en_US set as the default language.
PRODUCT_LOCALES := \
- en_US \
+ zh_CN \
+ en_US \
af_ZA \
am_ET \
ar_EG \
ur_PK \
uz_UZ \
vi_VN \
- zh_CN \
zh_HK \
zh_TW \
zu_ZA \