In my WebView I'm setting a WebViewClient
in order to evaluate some JavaScript
when the page finishes loading:
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl("javascript:registerObjectDetailsCallback(" +
"function(details) {" +
"if (details.length == 1) {" +
"window.location.href = 'callback:' + escape(details[0]);" +
"} else if (details.length > 1) {" +
"alert('Error: callback set by registerObjectDetailsCallback was passed multiple selection');" +
"}" +
"}" +
");");
}
}
I'm doing the same thing in iOS which produces expected results:
-(void) webViewDidFinishLoad:(UIWebView *)webView {
[serverWebView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"registerObjectDetailsCallback("
"function(details) {"
"if (details.length == 1) {"
"window.location.href = 'callback:' + escape(details[0]);"
"} else if (details.length > 1) {"
"alert('Error: callback set by registerObjectDetailsCallback was passed multiple selection');"
"}"
"})"]];
}
But no joy in android. Any ideas? Am I calling it at the wrong time? Should I be using WebChromeClient
?