I am making a custom softkeyboard. Is there anyway to check if it has been enabled in settings?
Check below code :-
String packageLocal = getPackageName();
boolean isInputDeviceEnabled = false;
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
List<InputMethodInfo> list = inputMethodManager.getEnabledInputMethodList();
// check if our keyboard is enabled as input method
for (InputMethodInfo inputMethod : list) {
String packageName = inputMethod.getPackageName();
if (packageName.equals(packageLocal)) {
Toast.makeText(getApplicationContext(),"Your Keyboard Enable",Toast.LENGTH_SHORT).show();
}
}
Turned out I just had to do this:
InputMethodManager im = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
String list = im.getEnabledInputMethodList().toString();
if(list.contains(<MY KEYBOARD ID>)){
//Do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With