0

in application I'm working on we want to add JS interface to the webview, but at the same time we want it to be only available for scripts on sites with a certain hostname (for example - only for sites that start with "www.google.com", but not on any other). Are there callbacks in which our interface could be added and removed in Webview class, or possible some other, like WebviewClient? Are there any other solutions that could help us?

I tried calling WebView.addJavascriptInterface in WebViewClient.onPageStarted, but it turns out addJavascriptInterface is an asynchronous method that adds a task to a queue (as described here: Understanding Android's webview addjavascriptinterface), so when it's called in onPageStarted it is added only after the page is actually loaded.

KubaK
  • 197
  • 2
  • 13

0 Answers0