【发布时间】:2015-12-18 09:44:43
【问题描述】:
参考this link,我正在构建一个更改android 设备系统区域设置的android 应用程序。它在印度语言印地语和孟加拉语的情况下工作正常,但对于其他印度语言,它不能完全工作(但在某些区域部分改变,比如部分时间的上午/下午)。我的示例代码sn-p:
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();
}
}
如果我通过 设置 -> 语言和输入 -> 语言 并在那里更改语言,我的设备并不是没有这些语言支持,有用。但是如何以编程方式进行呢?
【问题讨论】:
-
你的 logcat 有错误吗?
-
没有错误,只是没有完全改变。我也关注了this link@icyerasor 的回答,但结果相同。