[英]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.