2015-03-02 70 views
0

我想知道Android中用户选择的默认键盘。我知道我可以使用InputMethodManager访问启用的输入法列表,但我想知道用户当前正在使用哪一个。了解Android上的默认键盘

到目前为止,我一直试图让当前输入方法亚型:

InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE); 
InputMethodSubtype subtype =imeManager.getCurrentInputMethodSubtype(); 

但这对象只似乎给我的区域的用户的回升及输入类型(语音,键盘,。 )。

我也通过启用输入法列表中的尝试:

InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE); 
List<InputMethodInfo> list =imeManager.getEnabledInputMethodList(); 
    for(InputMethodInfo i: list){ 
     ... 
    } 

但是该类InputMethodInfo不包含这种方法是否为默认输入法与否的信息。

我知道必须有一个办法,因为每次我打开SwiftKey键盘,而不是设置为显示一个输入法选择器默认的键盘。那么,他们怎么知道他们的键盘目前没有被设置为默认?

我知道这个问题可能是重复的,因为它是一样的this之一。然而,这个问题没有得到答案,所以我真的希望有人能帮助我。

谢谢。

回答

3

使用此得到默认的键盘。

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))) { 
    ... 
    } 
} 
相关问题