2

I have created a WebView activity like the following. I'm not able to make it working.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    JAsocket socket1=new JAsocket();

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);

        webView.addJavascriptInterface(socket1, "socket");

    webView.loadUrl("file:///android_asset/index.html");
     webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);

}

My question is if I manipulate some member variables of "socket1" by calling its function in javascript via "socket",can I see those changes in this activity using socket1 as I pass the same object to the javascript.

Thanks.

1 Answer 1

1

The answer to your question is yes, sure. Have a look at a few examples.

http://android-developers.blogspot.in/2008/09/using-webviews.html

http://techdroid.kbeanie.com/2010/10/android-webview-javascript-and-css.html

You are half way through by the way.

Sign up to request clarification or add additional context in comments.

1 Comment

would've upvoted if the answer actually contained any info besides external links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.