I wanted to make my own Https Get/Post request on Android platform. In this blog post I will cover my investigation and the quirks I noticed for eg.
- if you are working over wifi behind a proxy server or 3G.
- or what classes to use.
A standard Http 1.1 requests can be made using Java standard HttpUrlConnection class. There is a separate HttpsUrlConnection class for https connections. But now you will also have to write code if(http) use HttpUrlConnection elseif(https) use HttpsUrlConnection.
However, Android comes with Apache HttpClient library (which builds on Sockets) and
Android itself uses this library at various places.
// set proxy
HttpHost proxy = new HttpHost("myproxy server", 80);
HttpParams params = new BasicHttpParams();
HttpClient httpClient = new DefaultHttpClient(this.manager, params); // this.manager is an instance of HttpConnectionManager
WebView behaves like the browser. All of the below is true for wifi.
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
Unfortunately, the function is not present on Android 2.1. Fortunately, there is an easy workaround which can be followed.
very helpful article. Have you ever managed to establish a https connection with a digital certificate via WebView in Android? If yes, I would be very grateful if you post the code
Hi Victor, yes webview does loads websites on https connection with a digital certificate. It should be very straight forward. If you are seeing any errors then try to catch them in onReceivedSslError function as I mention in the blog post.