-1

How can I know in Android WebView that video is clicked?

For example: When I run Facebook in web view and in it when I click on video Toast come and tell me that video is clicked.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

1

You can add JavascriptInterface to WebView and capture the click by VideoObjectID on your HTML page.

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.addJavascriptInterface(new Object() {
      public void performClick() {
        // Deal with a click on the WebView's Video Object ID
      }
    }, "video_object_id");

You HTML must have something similar to below:

<div type="video_object_id" onclick="performClick();">Play Video</div>
Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126