How to switch between Virtual Keyboard and Default Soft Keyboard

398 Views Asked by At

IMPORTANT

I am developing an app in which I have integrated virtual keyboard for emojies using InputMethodService. Now, I can switch from my Virtual keyboard to default softkeyboard as below :

emojiKeyboard.switchToPreviousInputMethod();

where emojiKeyboard is the object of EmojiKeyboardService class which extends InputMethodService

The method switchToPreviousInputMethod() is as below :

public void switchToPreviousInputMethod() {
    Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vib.vibrate(25);
    try {
        previousInputMethodManager.switchToLastInputMethod(iBinder);
    } catch (Throwable t) { // java.lang.NoSuchMethodError if API_level<11
        Context context = getApplicationContext();
        CharSequence text = "Unfortunately input method switching isn't supported in your version of Android! You will have to do it manually :(";
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    }
}

So, switching to my Virtual keyboard is headache. Is there any way to do it programmatically ? Because I can set it from device settings again.

But, We know that it should not that User has to go to settings each time when he switched to default soft keyboard.

Please guide. Hope for the positive answer.

thanks.

0

There are 0 best solutions below