参考this link,i 'm building an android app which changes android device'的系统区域设置 . 它适用于印度语印地语和孟加拉语,但对于其他印度语言,它不能完全正常工作(但在某些方面部分改变,如am / pm部分时间) . 我的示例代码段:
public void toEnglish(View v){
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config;
try {
config = am.getConfiguration();
config.locale = Locale.US;
am.updateConfiguration(config);
//Trigger the dirty bit for the Settings Provider.
BackupManager.dataChanged("com.android.providers.settings");
} catch (Exception e) {
e.printStackTrace();
}
}
public void toHindi(View v) {
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config;
try {
Locale locale = new Locale("hi");
config = am.getConfiguration();
config.locale = locale;
am.updateConfiguration(config);
//Trigger the dirty bit for the Settings Provider.
BackupManager.dataChanged("com.android.providers.settings");
} catch (Exception e) {
e.printStackTrace();
}
}
public void toTamil(View v) {
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config;
try {
Locale locale = new Locale("ta");
config = am.getConfiguration();
config.locale = locale;
am.updateConfiguration(config);
//Trigger the dirty bit for the Settings Provider.
BackupManager.dataChanged("com.android.providers.settings");
} catch (Exception e) {
e.printStackTrace();
}
}
它不像我在我的设备中没有这些语言支持,如果我通过 Settings -> Language & input-> Language 并在那里更改语言,它可以工作 . 但是如何以编程方式进行呢?
1 回答
在初始化语言环境时添加国家/地区字符串对我来说是个窍门 . 在这里我添加字符串“IN” .