Is it possible to know the keyboard being used by the user? How do I check if the user is using a Swype keyboard?
Asked
Active
Viewed 2,776 times
3 Answers
13
You can retrieve the current default keyboard using:
String currentKeyboard = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
You will get a result like com.touchtype.swiftkey/com.touchtype.KeyboardService
for various keyboards. The first part is the main package name of the keyboard, and the second is the name of the Keyboard Service it uses. Simply parse this String to see if it matches the info for Swype (I can only provide SwiftKey's details right now, as I don't have Swype installed).

Raghav Sood
- 81,899
- 22
- 187
- 195
-
Thanks! :) I got it now! Without the explanation and assignment of the variable, I thought the code is for selecting what keyboard is going to be used. – Arci Jan 17 '13 at 02:20
-
Check this answer: https://stackoverflow.com/questions/8165618/how-to-check-if-the-native-hardware-keyboard-is-used/12557231#12557231 – Rafael Jan 02 '19 at 09:09
2
Looks like your answer is here:
How to determine the current IME in Android?
Sometimes it's just about knowing the right search term.

Community
- 1
- 1

anthropomo
- 4,100
- 1
- 24
- 39
-
1And here is everything else: http://developer.android.com/reference/android/provider/Settings.Secure.html – anthropomo Jan 17 '13 at 02:09
-
Thanks! Yes, I tried to search for it but it seems that I'm not using the correct keyword. I want to set your answer as the correct answer but Raghav also posted the answer here with explanation. – Arci Jan 17 '13 at 02:17
-
Completeness wins the day. That's fair. Thanks for the upvote (I assume ti's from you) in any case. – anthropomo Jan 17 '13 at 02:18
1
The following lets you determine if Samsung, Google, or Swype keyboard is used.
public boolean usingSamsungKeyboard(Context context){
return usingKeyboard(context, "com.sec.android.inputmethod/.SamsungKeypad");
}
public boolean usingSwypeKeyboard(Context context){
return usingKeyboard(context, "com.nuance.swype.input/.IME");
}
public boolean usingGoogleKeyboard(Context context){
return usingKeyboard(context, "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME");
}
public boolean usingKeyboard(Context context, String keyboardId)
{
final InputMethodManager richImm =
(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isKeyboard = false;
final Field field;
try
{
field = richImm.getClass().getDeclaredField("mCurId");
field.setAccessible(true);
Object value = field.get(richImm);
isKeyboard = value.equals(keyboardId);
}
catch (IllegalAccessException e)
{
}
catch (NoSuchFieldException e)
{
}
return isKeyboard;
}

Chris Sprague
- 3,158
- 33
- 24