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);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…