增加英文、阿拉伯文输入法
修改代码:
1、frameworks\base\packages\SettingsProvider\res\values\defaults.xml
<string name=”def_input_methods”>com.android.inputmethod.latin/.LatinIME;-921088104;1494081088</string>
2、frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java
loadSecureSettings方法中增加:
loadStringSetting(stmt,Secure.ENABLED_INPUT_METHODS,R.string.def_input_method);
android/packages/inputmethods/LatinIME/java/res/xml/method.xml中有定义的
英文(en_US) 0xc9194f98 -921088104
阿拉伯文(ar) 0x590dde40 1494081088
源码中packages\inputmethods\LatinIME\java\res\xml\method.xml可以看到对应的值
也可以写调试代码:
private static final String[] DEFAULT_LANGUAGES = {"en_US","ru"};//英语,俄语
private void getCommoit(Context context) {
final String serviceName = "com.android.inputmethod.latin/.LatinIME";
final String currentPackageName = "com.android.inputmethod.latin";
final String enable = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ENABLED_INPUT_METHODS);
final InputMethodManager imm = (InputMethodManager) context.getSystemService( Context.INPUT_METHOD_SERVICE);
final StringBuilder builder = new StringBuilder();
for (InputMethodInfo info : imm.getInputMethodList()) {
if (currentPackageName.equals(info.getPackageName())) {
for (int i = 0; i < info.getSubtypeCount(); i++) {
final InputMethodSubtype subtype = info.getSubtypeAt(i);
final String locale = subtype.getLocale().toString();
if (isDefaultLocale(locale)) {
builder.append(';');
builder.append(subtype.hashCode());
}
}
break;
}
}
if (builder.length() > 0 && !TextUtils.isEmpty(enable)) {
final String subtype = builder.toString();
builder.setLength(0);
final int index = enable.indexOf(serviceName) + serviceName.length();
if (enable.length() > index) {
builder.append(enable.substring(0, index));
builder.append(subtype);
builder.append(enable.substring(index));
} else if (enable.length() == index) {
builder.append(enable);
builder.append(subtype);
} else {
return;
}
}
else {
return;
}
//这里是我想要的信息了
Log.i(TAG,"debug by 123 commoit:"+builder.toString());//com.android.inputmethod.latin/.LatinIME;-921088104;1983547218
}
private boolean isDefaultLocale (String locale) {
final String[] locales = DEFAULT_LANGUAGES;
for (String str : locales) {
if (str.equals(locale)) {
return true;
}
}
return false;
}
Android 输入法增加语言_bdd学android的博客-CSDN博客
今天的文章LatinIME默认打开各国语言分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/24612.html