Android WebView 中只有一个 javascript 警报,然后它停止响应
我在 WebChromeClient 中为嵌入的 WebView 设置了一个 javascriptalert() 处理程序:
@Override
public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result)
{
Log.d("alert", message);
Toast.makeText(activity.getApplicationContext(), message, 3000).show();
return true;
};
不幸的是,这只显示弹出 toast 一次,然后 WebView 停止响应任何事件。我什至无法使用菜单命令加载另一个页面。我在 LogCat 中没有看到错误,这可能是什么问题?
I set up a javascript alert() handler in a WebChromeClient for an embedded WebView:
@Override
public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result)
{
Log.d("alert", message);
Toast.makeText(activity.getApplicationContext(), message, 3000).show();
return true;
};
Unfortunately, this only shows a popup toast once, then the WebView stops responding to any events. I can't even use my menu command to load another page. I don't see errors in LogCat, what could be the problem here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要对
JsResult result
参数调用cancel()
或confirm()
。You need to invoke
cancel()
orconfirm()
on theJsResult result
parameter.添加这个
add this