Webview loads url with shouldOverrideUrlLoading and then again with loadResources (sometimes!)
===

I have an intermittent issue where I have a custom protocol and the webview attempts to load the url twice causing an error.

So the JS has a call such as:
myproto://param1&param2&param3

In my webViewClient I override the methods with:

     public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Uri uri = Uri.parse(url);
            String scheme = uri.getScheme();
            
            if (scheme.equals("myproto")) {
            	doCustomStuff(URI.create(url));
            	return true;
            }
            
            return false;
      }

In most cases the code executes as expected however 30% of the time shouldOverrideUrlLoading gets called as normal but then gets followed by a onPageStarted and onLoadResource. This causes an unsupportedProtocol error as onLoadResource doesn't know what to do with my custom protocol.

As far as I can tell all the methods are getting called from the same place in the JS with the same url (I added a tracking variable in the JS).

Again this doesn't happen all the time. Does anyone one have any ideas as to why this is happening?

THanks

KK
