Switch Keyboard Profile Programmatically

Switch keyboard profile programmatically

This piece of code will fulfill your requirements:

InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();

As Commonsware points out in his answer, there is no way to do this behind the user's back.

Programmatically enabling a custom keyboard

Just open input method settings activity using Intent.

Intent enableIntent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
enableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(enableIntent);

How to get this dialog to change the keyboard android programmatically

InputMethodManager imeManager = (InputMethodManager) 
getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();

Programmatically change Keyboard Layout

Use this command

powershell -command "Set-WinUserLanguageList -Force 'en-US'"

or

powershell -command "Set-WinUserLanguageList -Force 'fr-FR'"

Change keyboard language programmatically

There is a big work around about how to do this - which is create your own keyboard, and to do this you'll have to know the keyboards you're aiming for. (which will be exact duplicate of the regular keyboard)

General guide on the subject here & code samples.

Create a custom keyboard View which extends keyboardView

In it create static key value variable like

static final int KEYCODE_LANGUAGE_SWITCH_ENG = -102;
static final int KEYCODE_LANGUAGE_SWITCH_URDU = -103;

after that in your IME class where you have implemented the inputMethodService, create the keyboards inside the onInitializeInterface override function. like

mSymbolsKeyboard = new Keyboard(this, R.xml.qwerty2);
mEngQwertyKeyboard = new Keyboard(this, R.xml.eng_qwerty);

after this add these final static keys in the onKey override function as switch cases, and in the cases set the keyboards accordingly:

setKeyboard(mEngQwertyKeyboard);


Related Topics



Leave a reply



Submit