开发者

How to request a secured connection (https)?

Generally, we use http connection like this:

try{

            HttpClient httpclient = new DefaultHttpClient();
//              final HttpParams params = httpclient.getParams();
//              HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);
//              HttpConnectionParams.setSoTimeout(params, WAIT_TIMEOUT);
//              ConnManagerParams.setTimeout(params, WAIT_TIMEOUT);

                HttpPost httppost = new HttpPost(url);
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();

        }catch(开发者_如何学编程Exception e){
              // Log.e("log_tag", "Error in http connection "+e.toString());
        }

This code snippet is used for http.

How can I request a secured connection (https) ?


If you are after Android 2.2, you can simply use class AndroidHttpClient.
It will be work through https, if url scheme is https.

Otherwise, you can look to its source and make similar, and may be even easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜