作者:NarratorWang | 来源:互联网 | 2023-05-19 19:23
我想知道用户在Android中选择的默认键盘.我知道我可以使用它来访问已启用的输入法列表InputMethodManager
,但我想知道哪个是当前正在使用的用户.
到目前为止,我已经尝试获取当前的输入法子类型:
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
InputMethodSubtype subtype =imeManager.getCurrentInputMethodSubtype();
但是这个对象似乎只给了我用户选择的Locale和输入类型(语音,键盘,......).
我也尝试了启用输入法的列表:
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
List list =imeManager.getEnabledInputMethodList();
for(InputMethodInfo i: list){
...
}
但是,该类InputMethodInfo
不包含此方法是否为默认输入方法的信息.
我知道必须有一种方法,因为每次我打开SwiftKey键盘并且没有设置为默认键盘时会出现输入法选择器.那么,他们怎么知道他们的键盘当前没有设置为默认值?
我知道这个问题可能是重复的,因为它是一样的这一个.然而,这个问题没有得到答案,所以我真的希望有人可以帮助我.
谢谢.
1> Hemanth..:
使用它来获取默认键盘.
Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
要获取有关当前键盘的更多信息:
for(InputMethodInfo i: list){
if (i.getId().equals(Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD))) {
...
}
}