Android Http Get maybeCreateHttpClient()

Here you can find the source of maybeCreateHttpClient()

Description

Configures the httpClient to connect to the URL provided.

Declaration

public static void maybeCreateHttpClient() 

Method Source Code

//package com.java2s;

import org.apache.http.client.HttpClient;

import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class Main {
    public static final int REGISTRATION_TIMEOUT = 30 * 1000;
    protected static HttpClient mHttpClient;

    /**/*from ww  w .  j a  va2 s.co  m*/
     * Configures the httpClient to connect to the URL provided.
     */
    public static void maybeCreateHttpClient() {
        if (mHttpClient == null) {
            mHttpClient = new DefaultHttpClient();
            final HttpParams params = mHttpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params,
                    REGISTRATION_TIMEOUT);
            HttpConnectionParams.setSoTimeout(params, REGISTRATION_TIMEOUT);
            ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT);
        }
    }
}

Related

  1. getStringFromConnection( HttpURLConnection connection)
  2. httpGetRequestParseParams( String paramString)
  3. formatHttpHeaders(Map headers)
  4. getStringResponseData(HttpResponse httpResponse)
  5. getHttpClient()
  6. sendGetRequest(String path)
  7. fetchData(String url)