Code example for HttpHost

0
		return !TextUtils.isEmpty(Proxy.getDefaultHost());
	} 
	 
	/// get proxy if has 
	static HttpHost getProxy() {
		return new HttpHost(Proxy.getDefaultHost(), Proxy.getDefaultPort());
	} 
	 
	/// create http client 
	static DefaultHttpClient createHttpClient(int timeout) {
		// wifi connected? 
		boolean wifi = isWifiConnected();
		 
		// create client 
		SchemeRegistry schemeRegistry = new SchemeRegistry();
		schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
		try { 
			schemeRegistry.register(new Scheme("https", new TrustAllSSLSocketFactory(), 443));
		} catch (Exception e) {
		} 
		HttpParams params = new BasicHttpParams();
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setContentCharset(params, "UTF-8");
		HttpProtocolParams.setUseExpectContinue(params, false);
		HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY);
		HttpConnectionParams.setConnectionTimeout(params, wifi ? timeout : (timeout * 3));
		HttpConnectionParams.setSoTimeout(params, wifi ? timeout : (timeout * 3));
		ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, schemeRegistry);
		DefaultHttpClient client = new DefaultHttpClient(ccm, params);
		 
		if(!wifi && hasProxy()) {
			HttpHost proxy = getProxy();
			if(proxy != null)
				client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
		} 
 
		return client;
	}