In a WebView is there a way for shouldOverrideUrlLoading to determine if it is catching a redirect vs. a user clicking a link?

前端 未结 6 629
时光说笑
时光说笑 2021-02-01 06:06

I would like to allow redirects to happen naturally in the WebView and only catch a new url if it is a happening because a user clicked something.

6条回答
  •  渐次进展
    2021-02-01 06:47

    You can do as follow:

    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url) {
        if (webView.getUrl() != null && webView.getOriginalUrl() != null && webView.getOriginalUrl().equalsIgnoreCase(webView.getUrl()) {
            // Not Redirect
        } else {
            // Redirect
        }
    }
    

提交回复
热议问题