0

On Android, can we change the keyboard input language (English(US), Hindi, French, etc.) from Java/C++ or the terminal(like the imein /system/bin?

Arav K.
  • 110
  • 3
  • 12
  • 1
    I don't think it is possible. Since the keyboard is itself an application. See : http://stackoverflow.com/questions/12303593/change-keyboard-input-language – KISHORE_ZE Jun 30 '16 at 12:24
  • Yes it's not possible please check below answer https://stackoverflow.com/questions/12303593/change-keyboard-input-language – Akshay Panchal Jun 30 '16 at 12:40

1 Answers1

3

For those who said not possible here it is, it's very much possible but device needs to be rooted or your app needs to be system signed.

protected static void changekeyboard(String keyboardID, ContentResolver contentResolver)
    {
        String oldDefaultKeyboard = Secure.getString(contentResolver, "default_input_method");
        Secure.putString(contentResolver, "enabled_input_methods", keyboardID);
        Secure.putString(contentResolver, "default_input_method", keyboardID);
    }

in keyboardID you need to pass the keyboardID of the keyboard you want to set.

or you may get the list of all keyboards and get the ID from there and pass it

Like this:

 List<InputMethodInfo> InputMethods = ((InputMethodManager) getApplicationContext().getSystemService("input_method")).getInputMethodList();
            this.keyboard_name = new ArrayList();
            int numOfKeEyboards = InputMethods.size();
            for (int i = 0; i < numOfKeEyboards; i++)
            {
                fullKeyboardName = ((InputMethodInfo) InputMethods.get(i)).toString();
                keyboard_package = fullKeyboardName.substring(fullKeyboardName.indexOf("{") + 1, fullKeyboardName.indexOf("/"));
                try
                {
                    // by package name getting app name
                    inputKeyboardName = getPackageManager().getApplicationInfo(keyboard_package, 0).loadLabel(getPackageManager()).toString();
                }
                catch (NameNotFoundException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                this.keyboard_name.add(inputKeyboardName);
            }
Flexo
  • 84,884
  • 22
  • 182
  • 268
tanmeet
  • 212
  • 2
  • 11