There are a few things you need to check with your code.
First, in your HTML, the <script>
tag at the top is not closed. Please add a </script>
after your last function definition.
Second, in the Java, please configure your WebView before calling loadUrl
. Settings and JavaScript interfaces should be registered first.
Third, there's no need to use a Button
widget to achieve the effect you are looking for. Something like this should be perfectly adequate:
webview.addJavaScriptInterface(new Object() {
@JavaScriptInterface
public void performClick() {
Intent i = new Intent(this, CloudReco.class);
startActivity(i);
}
}, "valid");
and similar for "refuse".