Suraj Neupane Suraj Neupane - 1 year ago 144
Android Question

set/get Data in webview android

I have this webview:

<textarea name="text" id="textPage" class="text_area"></textarea>
<script language="javascript" charset="utf-8">
//call some method of javascript.

Is it possible to set text to textarea and get text from textarea.
Set/get data from id(if any method possible) will be appreciated.

Answer Source

After many research i found solution, it might useful in future:

Set Data:




function setData(){
//js code

Get Data:


JavascriptInterface jsInterface = new JavascriptInterface(MainActivity.this);
converterWeb.addJavascriptInterface(jsInterface, "Android");//android is a tag.


public class JavascriptInterface {
        Context mContext;

        JavascriptInterface(Context c) {
            mContext = c;

        public boolean getData(String name) {
            Toast.makeText(mContext, "Text: "+name, Toast.LENGTH_SHORT).show();
            return true;


Android.convertedText(value);//send data in tag.

better option still welcome.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download