I have a custom keyboard in Android. I want to have a button on my keyboard that when pressed will hide my keyboard and show the keyboard that the user has specified as the default keyboard. (If worst comes to worst, I will accept a solution that just shows the default Android keyboard that is not specified by the user).
I tried this code:
private void showSoftKeyboard()
{
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);
}
But that did nothing.
What should I do?
Edit One:
I am documenting my progress in figuring this out.
So far I have figured out how to get the default user set keyboard:
String currentKeyboard = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
Based off of this post: How to detect if user's keyboard is Swype?
I believe there is a method in the InputMethodManager
class that allows you to set the InputMethod. I believe this is true due to this post: Android: switch to a different IME programmatically
Now I just have to figure out how to figure out how to get the id of the default keyboard and then I can implement this feature.