Sonal Maheshwari
Sonal Maheshwari

Reputation: 217

webpage in webview is blank

I am using the code below to connect to https site. But the result is always a blank page. I have already searched alot. Any help will be appreciated.

    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;
    }

Upvotes: 0

Views: 257

Answers (1)

Ruuhkis
Ruuhkis

Reputation: 1934

have you tried something as simple as

webview.loadUrl("URL HERE");

Upvotes: 1

Related Questions