It wasn't showing JSAlert on any devices. And then I set a WebChromeClient:
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {
return super.onJsAlert(view, url, message, result);
}
@Override
public boolean onJsPrompt(WebView view, String url, String message,
String defaultValue, JsPromptResult result) {
return super.onJsPrompt(view, url, message, defaultValue,
result);
}
});
Now it works fine on all pre-Lollipop devices. And doesn't show any alert on Lollipop devices.
Logcat says "Cannot create a dialog, the WebView context is not an Activity".
There is a bug introduced in version 40 of WebView, and is fixed in version 42.
Check the issue reported at
https://code.google.com/p/chromium/issues/detail?id=478204
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With