[英]XWalkView prevent navigation
I have a XWalkView in my andoid app that is used to display a single page, this page has a lot of popup ads and my goal is to prevent the XWalkView from navigating to other pages than the one I set it to. 我的Andoid应用程序中有一个XWalkView,用于显示单个页面,该页面上有很多弹出广告,我的目标是防止XWalkView导航到除我设置的页面之外的其他页面。 In the UWP version of my app I wrote:
在我的应用程序的UWP版本中,我写道:
private void webView_NewWindowRequested(WebView sender, WebViewNewWindowRequestedEventArgs args)
{
args.Handled = true;
}
and that solved that. 这就解决了。 Is there any similar way to do this with XWalkView?
使用XWalkView有类似的方法吗? Or any way at all?
还是任何方式?
If you override shouldOverrideUrlLoading
, you can return true
to indicate that the request has been handled. 如果您覆盖了
shouldOverrideUrlLoading
,则可以返回true
,表明请求已被处理。
xwalkview.setResourceClient(new XWalkResourceClient(xwalkview) {
@Override
public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
return !url.equals(MY_URL);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.