Is there a WebView onReceivedError equivalent for GeckoView?

64 views Asked by At

When using WebView I can handle errors with onReceivedError and onReceivedHttpError. How do I do this with GeckoView?

Searched through documentation, I expected to find a similar method for GeckoSession but I can't find any.

2

There are 2 answers

0
Vince On

I found it. This can be done by overriding GeckoSession.NavigationDelegate.onLoadError.

See WebResponse for HTTP error codes.

1
Nina Gos On

Just set NavigationDelegate to your Gecko Session.

 geckoSession.setNavigationDelegate(new GeckoSession.NavigationDelegate() {
            @Nullable
            @Override
            public GeckoResult<String> onLoadError(@NonNull GeckoSession session, @Nullable String uri, @NonNull WebRequestError error) {
                return GeckoSession.NavigationDelegate.super.onLoadError(session, uri, error);
            }
        });