简体   繁体   English

XWalkView阻止导航

[英]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.

相关问题 是否有XWalkView webview客户端? - Is there a XWalkView webviewclient? 如何为XWalkView设置颜色过滤器? - How to set a color filter for XWalkView? 如何在服务中创建XWalkView? - How to create an XWalkView within a service? 是否可以阻止Android &lt;4.4上的导航栏? - Is it possible to prevent the navigation bar on Android <4.4? 膨胀 class org.xwalk.core.XWalkView 时出错 - Error inflating class org.xwalk.core.XWalkView 如何防止显示状态栏和导航? - How do I prevent the Status Bar and Navigation from ever showing? 如果已经打开碎片,如何防止在导航抽屉中打开该碎片 - How to prevent opening a fragment in navigation drawer if that fragment is already opened 滚动 CoordinatorLayout 时如何防止底部导航隐藏 - How to prevent bottom navigation from hiding when scrolling a CoordinatorLayout 如何防止 Android Studio 在项目导航中自动折叠我的包? - How do I prevent Android Studio from automatically collapsing my packages in project navigation? 有没有一种方法可以防止在使用Android导航组件时在bottomNavigation中重新创建片段 - Is there a way to prevent re-create fragment in bottomNavigation when using android navigation component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM