XWalkView prevent navigation

83 Views Asked by At

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. In the UWP version of my app I wrote:

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? Or any way at all?

1

There are 1 best solutions below

0
user650881 On

If you override shouldOverrideUrlLoading, you can return true to indicate that the request has been handled.

xwalkview.setResourceClient(new XWalkResourceClient(xwalkview) {
    @Override
    public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
        return !url.equals(MY_URL);
    }
});