Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Know default keyboard on android

I want to know the default keyboard chosen by the user in Android. I know I can access the list of enabled input methods using the InputMethodManager, but I want to know which one is the user currently using.

So far, I've tried to get the current input method subtype:

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

But this object only seems to give me the Locale the user has picked and the input type (voice, keyboard,..).

I've also tried through the list of enabled input methods:

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

However the class InputMethodInfo does not contain information of whether this method is the default input method or not.

I know there must be a way, because everytime I open SwiftKey Keyboard and is not set as the default keyboard a input method picker appears. So, how do they know their keyboard is not currently set as default?

I'm aware this question might be a duplicate, since it's the same as this one. However that question didn't get an answer, so I'm really hoping someone can help me now.

Thank you.

like image 391
ACBM Avatar asked Mar 17 '23 21:03


1 Answers

Use this to get default keyboard.

Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);

To get more information about current keyboard:

for(InputMethodInfo i: list){
  if (i.getId().equals(Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD))) {
like image 200
Hemanth Avatar answered Mar 29 '23 18:03