2014-10-07 69 views
0

这是我的代码:找不到网页,Android的web视图

public class MyActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_web_view); 
     WebView webview = (WebView) findViewById(R.id.webView); 

     /*webview.setWebViewClient(new WebViewClient() { 
      @Override 
      public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 
        Log.i("WEB_VIEW_TEST", "error code:" + errorCode); 
        super.onReceivedError(view, errorCode, description, failingUrl); 
      } 
     });*/ 

     webview.loadUrl("www.google.com"); 

    } 

... 
... 
... 

我设置清单中的Internet权限。 如果我取消注释setWebViewClient的结果是一样的。

我该如何解决我的问题?

+4

尝试'的https:// www.google.com' – 2014-10-07 10:23:22

+0

而且你真的连上网?检查一次。 – 2014-10-07 10:28:30

+2

AabraKaDabra正在发生:-) – 2014-10-07 10:29:37

回答

0

WebView不假设您想要默认使用HTTP。使用WebView解析URL时,您需要始终标识您希望用来检索资源的协议。

因此而不是只指定www.google.com加载与网站:

webview.loadUrl("http://www.google.com");