2

Is it possible to popup virtual keyboard when some command is being received from server? I am trying to call focus on text area but soft keyboard is not coming. I agree that for keyboard to popup, user event is required. Is there any way to show virtual keyboard forcefully? I am talking about web app inside Android chrome browser.

Manu
  • 806
  • 1
  • 9
  • 25
user1659302
  • 91
  • 1
  • 3

3 Answers3

2

You can do this by calling focus() then click() on the input, but, as you say, only when the script is initiated by user input. My current answer, having spent a day fiddling, is that there is no way to get around this.

bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
  • Thanks, "calling `focus()` then `click()` on the input" was precisely what I was looking for and it worked. – Dário Mar 17 '18 at 01:45
0

This question may help you: Showing Android's soft keyboard when a field is .focus()'d using javascript

In your case you could try to have a hidden text input field on your page and trigger a click event on it when the command is received from the server.

Community
  • 1
  • 1
sdabet
  • 18,360
  • 11
  • 89
  • 158
-1
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

May this will help you

Dinesh Prajapati
  • 9,274
  • 5
  • 30
  • 47