I want to make a synchronous call to some Java code in my Android app.
I am using this solution: https://stackoverflow.com/a/3338656
My Java code:
final class MyWebChromeClient extends WebChromeClient {
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
Log.d("LogTag", message);
result.confirm();
return true;
}
}
My JavaScript code:
<html>
<script>
function java_request(){
alert('test');
}
</script>
<body>
<h2>Welcome</h2>
<div id="area"></div>
<form>
<input type="button" value="java_call" onclick="java_request()">
</form>
</body>
</html>
When I tap on the java_call
button, the button goes to the pressed state. I can see 'test'
in the console log. Everything is normal until here.
The problem is, the button never gets back to its normal state. It stays in the pressed state. Maybe the JavaScript execution is broken or something?
Why does the button never return to its normal state?