简体   繁体   中英

Detect Click on WebView in ANDROID with HTML data

I am trying to find whether a user clicks a webview in android. The WebView Contains some html/javascript that loads. I want to find whether the user clicks the webview.

thanks for the help.

the code is something like this:

//....//

    wv = (WebView) findViewById(R.id.webView1);

    wv.getSettings().setJavaScriptEnabled(true);

    wv.setBackgroundColor(Color.TRANSPARENT);
    String html = "<html><body style='margin:0;padding:0;'><script='text/javascript' src='URL'></script></body></html>";

    wv.loadData(html, "text/html", "utf-8");

//....//

thanks for the help....

Create handler in your android application like

wv.addJavascriptInterface(new JavaScriptHandler(this),"MyHandler");

And in your HTML using action listener callback method with your android handler then you can monitor your webview activities from android Similar Example Here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM