There is a WebView , it loads the html page (from the assets folder in the project) in which there is a form with textarea ...

How to make that when calling the setText("text"); method setText("text"); in the MainActivity text from the setText("text"); method was inserted into my textarea form setText("text"); ?

    1 answer 1

    1. Define a function in JS:

       function callFromActivity(msg){ // здесь строка, переданная из Java } 
    2. In the Java part, call webView.loadUrl("javascript:callFromActivity(\"Привет\")");

    In the JS method callFromActivity do with the text that your heart desires.

    • Your example does not work ... - Vadim
    • What mistake? JS have WebView included? - Suvitruf
    • I think this is through the fact that the page (index.html) in the assets folder and not on the server ... is there another way? - Vadim
    • No errors .. just does not insert the text .. js on - Vadim
    • @ Vadim show the code of your index.html . First, output msg in the callFromActivity method: alert(msg); write there. - Suvitruf