My application needs to retrieve data from a web site.
I use a webview
to access the required page. In the page displayed in this webview
there are links leading to the detailed info that the app needs. When following a link (using the webView.loadUrl()
) a popup is displayed on top of the webview
.
The app gets access to the links with the following code:
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new BackgroundScriptInterface(), "HTMLOUT");
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url)
{
webView.loadUrl("javascript:window.HTMLOUT.processHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
}
});
and
public class BackgroundScriptInterface {
@JavascriptInterface
public void processHTML(String html) {
...
}
But this BackgroundScriptInterface
is not called when a popup displays.
How do I get access to the html contents of the popup?
EDIT As suggested by Eddie below, I've tried
webView.evaluateJavascript(item.competDetailUrl, new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
Log.d("competDetail", s);
}
});
The popup is still displayed as expected. However the value passed to the onReceiveValue
callback is "null".