简体   繁体   English

WebView没有打开google.com

[英]WebView is not opening google.com

My webview is able to load both https & http sites But not https://www.google.com 我的Web视图能够同时加载https和http网站,但不能加载https://www.google.com。

It doesn't throw any error either. 它也不会引发任何错误。

Here is my code.I am unable to solve this problem 这是我的代码,我无法解决这个问题

     super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final Button btn = (Button) findViewById(R.id.Button1);
        final EditText et=(EditText)findViewById(R.id.EditText1);
        final WebView wv1=(WebView)findViewById(R.id.WebView1);

        wv1.getSettings().setJavaScriptEnabled(true);
        wv1.getSettings().setDomStorageEnabled(true);
        wv1.setInitialScale(100);

        et.setFocusable(true);


        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                 wv1.loadUrl(et.getText().toString());  
            }
        });

        wv1.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return true;
            }
ca
            public void onPageFinished(WebView view, String url) {
                Toast.makeText(getApplicationContext(),"Page Finished",Toast.LENGTH_LONG).show();
            }

            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_LONG).show();
            }
        });

        wv1.loadUrl("https://www.bing.com");

Thanks for any kind of help. 感谢您的任何帮助。

There is a bug in your code 您的代码中有一个错误

Your code 您的密码

public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }

Correct code 正确的代码

 public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }

ShouldOverrideUrlLoading should return false to open url in webview . ShouldOverrideUrlLoading应该return false以便在webview中打开url True is for opening in some other app . True是用于在其他应用程序中打开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从搜索结果google.com打开应用,总是指向Android的WebView首页 - Opening the application from the results google.com, always directs to the home page of WebView Android 带有google.com的AdMob示例 - AdMob with google.com example Android Webview可以显示google.com,但不能显示localhost,而iPhone UIWebView可以显示localhost - Android Webview can show google.com but not localhost whereas iPhone UIWebView can show localhost 菜单样式应用程序,例如google.com Mobile - Menu style application, such as google.com Mobile 从PhoneGap(Android)访问外部URL(Google.com) - Access external URL(Google.com) from PhoneGap(Android) 如何让WebViewClient在自己的活动中加载非google.com的网站 - How to let WebViewClient load websites that are not google.com in own activity java.net.UnknownHostException:无法解析主机“ google.com” - java.net.UnknownHostException: Unable to resolve host “google.com” Google Maps链接正在Webview中打开 - Google maps link is opening in webview Asmack 18连接:google.com:5222异常:无法连接到talk.google.com远程服务器超时 - Asmack 18 connection : google.com:5222 Exception: Could not connect to talk.google.com remote-server-timeout 是否可以通过编程方式将默认搜索引擎从Google.com更改为其他Android浏览器 - Is it posible to change default search engine from Google.com to some other programmatically for Android browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM