user1141938
user1141938

Reputation: 29

Webview and HTTPS?

I was wondering if anyone can help me out?

I want to develop an app (webview) for android but it used to work with http:// links but somehow https:// links can't be opened. When I visit the normal site with my normal browser it asks for my permission for proceeding with a certificate.

My question is now how to allow the certificates and view HTTPS?

I will post my source below of my webview activity, thanks in advance :)

  package im.testing.a.cool.app;


import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebPageLoader extends Activity
{
    final Activity activity = this;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.main);
        WebView webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);


        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)
            {
                activity.setTitle("Grabbing the bits and the bytes..");
                activity.setProgress(progress * 100);

                if(progress == 100)
                    activity.setTitle(R.string.app_name);
            }
        });



        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
            {
                // Handle the error  (does the ssl goes hier?)

            engine = (WebView) findViewById(R.id.my_webview);
engine.setWebViewClient(new WebViewClient() {
 public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
 handler.proceed() ;
 }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url)
            {
                view.loadUrl(url);
                return true;
            }
        });

        webView.loadUrl("https://website.willnot.open");
    }
 }

Upvotes: 2

Views: 7655

Answers (1)

DroidEngineer
DroidEngineer

Reputation: 9

You can do it using android private API check it out Here

Upvotes: 1

Related Questions