So I would that editText.setText (str) works the same as textView.setText (str)
I'm sending a string from WebView to Android @JavascriptInterface. Strangely, EditText only makes setText (string) when the send button is clicked in the WebView as long as the onscreen keyboard is popped up / active.
If you don't see the input field below the keyboard, then:
- I close the onscreen keybord,
- click send button in WebView,
- click again in any input field (or also in android Input) so that the onscreen keybord pops up,
- at this moment the string is displayed in the EditText in @JavascriptInterface, received from WebView.
Funny if I show / receive the string in a TextView it works without any onsceen keyboard status, or click click.
what can I do, I have already tried
a runnable scheduler to send the string to EditText 500 ms later,
and tried to call external functions, and displayed the message string with toast before EditText - so the message always arrives - only EditText shows which only if the keyboard is still popped up in the WebView.
try to send a click event to WebView , but in this focus the keyboard do not popup
@JavascriptInterface
public void showMessageInEditText(String str) {
int test = 1;
// EditText not happy
if(1==test){ EditText editText = (EditText) findViewById(R.id.edit_txt_id);
editText.setText(str); }
if(2==test){ TextView editText = (TextView) findViewById(R.id.edit_txt_id);
editText.setText(str); }
// TextView always works:
if(3==test){ TextView textView = (TextView) findViewById(R.id.txt_id2);
textView.setText(str); }
}
/*
a strange difference:
textView.setText(str); // test=3 always works
editText.setText(str); // test=1 test=2 only works if
the onscreen keyboard is popped up / active,
for input in the WebView active,
and the send button is clicked exactly during this time,
the onscreen keyboard is popped up
*/
I updated program , try send to another Activity2 and then it is ok