无法在“应覆盖的Web视图"中获取网址 [英] Can't Get the url in the Should over overriding webview

查看:98
本文介绍了无法在“应覆盖的Web视图"中获取网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有Webview的android应用.

I am developing an android app, which has a webview in it..

在帖子中单击该帖子时,URL为 https://www.facebook.com/. webview的帖子URL不能进入,但应覆盖url,但webview会将Facebook重定向到该特定帖子,这是webviewclient的shouldoverriding方法中的url应该存在的问题

The URL is https://www.facebook.com/ when the post is clicked in the webview the post URL is not getting in should overidding url but webview is redirecting the facebook to that particular post what is the problem the url should be in the shouldoverriding method of the webviewclient

Here I am Setting the Custom WebView Client 

webView.setWebViewClient(new WebViewController());

public class WebViewController extends WebViewClient {
@Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            Log.e("urltop", str + " ==top");
            String str3 = "youtube";
            if (!str.contains("market://")) {
                if (!str.contains("mailto:") && !str.contains("play.google") && !str.contains("tel:") && !str.contains("intent:") && !str.contains("vid:") && !str.contains(str3) && !str.contains("fb-messenger://")) {
                    if (!str.contains("whatsapp://")) {
                        if (str.contains("m.me")) {
                            Log.e("urlm.me", str);
                            return true;
                        } else if (str.contains("jpg")) {
                            Log.e("urljpg", str);
                            return true;
                        }
                        return true;
                    } else {
                        Log.e("url", str);
                    }
                }
            }
            return true;
        }

先谢谢您了:)

推荐答案

只需使用shouldOverrideUrlLoading:

public class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.equals("YOURLINK")) {
            Intent intent = new Intent(getContext(), YourActivity.class);
            startActivity(intent);
            return true; // Handle By application itself
        } else {
            view.loadUrl(url);
            return true;
        }
    }
}

这篇关于无法在“应覆盖的Web视图"中获取网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆