2012-02-13 77 views
0

我使用下面的代码连接到https站点。但结果总是一片空白。我已经搜索了很多。任何帮助将不胜感激。webview中的网页为空白

public boolean shouldOverrideUrlLoading(WebView view, String url) 
    {  try 
     { 
      InputStream keyStoreStream = getResources().openRawResource(R.raw.jssecacerts); 
      KeyStore keyStore = null; 
      keyStore = KeyStore.getInstance("BKS"); 
      keyStore.load(keyStoreStream, "mypwd".toCharArray()); 

       KeyManagerFactory keyManagerFactory = null; 
      keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); 
      keyManagerFactory.init(keyStore, "mypwd".toCharArray()); 

      SSLContext context = SSLContext.getInstance("TLS"); 
      context.init(keyManagerFactory.getKeyManagers(), null, null); 

      alertbox("before response", url); 
      URL url1 = new URL(url); 
      HttpsURLConnection urlConnection = (HttpsURLConnection) url1.openConnection(); 
      urlConnection.setSSLSocketFactory(context.getSocketFactory()); 
      InputStream in = urlConnection.getInputStream(); 
      alertbox("response", convertToString(in)); 
      view.loadData(convertToString(in), "text/html", "utf-8");    
     } 
     catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
     return true; 
    } 

回答

1

你尝试过作为

webview.loadUrl("URL HERE"); 
+0

雅简单的东西......但我不想DAT ......我甲肝响应的基础上设置Cookie ...有什么办法同时使用此方法设置Cookie ... – 2012-02-13 16:24:58