Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if my custom keyboard has been enabled in settings

I am making a custom softkeyboard. Is there anyway to check if it has been enabled in settings?

like image 581
Roymunson Avatar asked Apr 24 '16 20:04

Roymunson


2 Answers

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();
        }
    }
like image 122
Patel Vicky Avatar answered Oct 19 '22 08:10

Patel Vicky


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
   }
like image 40
Roymunson Avatar answered Oct 19 '22 07:10

Roymunson