WebViewClient not calling shouldOverrideUrlLoading

后端 未结 10 2352
逝去的感伤
逝去的感伤 2020-12-15 18:44

The problem is rather simple. In the application we want to keep track of the current url being displayed. For that we use shouldOverrideUrlLoading callback fr

10条回答
  •  星月不相逢
    2020-12-15 19:16

    I had the same problem like you, and I've finished with extending of WebViewChromeClient with listening for callback to

    public void onReceivedTitle(WebView view, String title)
    
    mWebView.setWebChromeClient(mSWWebChromeClient);
    
    private WebChromeClient mSWWebChromeClient = new WebChromeClient() {
    
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
                if (!view.getUrl().equals(mCurrentUrl)) {
                    mCurrentUrl = view.getUrl();
                    //make something
                }
            }
    
        }; 
    

提交回复
热议问题