Open soft keyboard programmatically

I have used the following lines to display the soft keyboard manually inside the onclick event, and the keyboard is visible.

InputMethodManager inputMethodManager =
    (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
    linearLayout.getApplicationWindowToken(),
    InputMethodManager.SHOW_FORCED, 0);

But I’m still not able to open this while the activity gets opened, so are there any solution for this?

Leave a Comment