0
点赞
收藏
分享

微信扫一扫

当切换系统语言时输入法会切换到原生输入法的规避方案


问题背景:

在项目实施过程中遇到客户反馈,当去切换语言时输入法变为默认输入法。

解决方案:

frameworks/base/services/core/java/com/android/server/InputMethodManagerService.java
InputMethodManagerService 构造函数中注释掉对语言更改时对输入法的更改,如下:

// IMMS wants to receive Intent.ACTION_LOCALE_CHANGED in order to update the current IME
// according to the new system locale.
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
mContext.registerReceiver(
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
synchronized(mMethodMap) {
resetStateIfCurrentLocaleChangedLocked();
}
}
}, filter);

总结:

虽然方案比较挫,但对项目来说解决问题是第一要务。


举报

相关推荐

0 条评论