Android ThreadSafeClientConnManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ThreadSafeClientConnManager class.

This code example shows how to use the following methods:setDefaultMaxPerRoute, setMaxTotal
 
  private static ClientConnectionManager getClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(registry);
    cm.setMaxTotal(2000);
    cm.setDefaultMaxPerRoute(2000);
    return cm;
  } 
 
  public HttpClient getHttpClient() {
    return httpClient;
  } 
 
  public HttpClient getGridHttpClient(int connection_timeout, int socket_timeout) {
    DefaultHttpClient gridClient = new DefaultHttpClient(gridClientConnectionManager);
    gridClient.setRedirectStrategy(new MyRedirectHandler());
    gridClient.setParams(getGridHttpParams(connection_timeout, socket_timeout));
    gridClient.setRoutePlanner(
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
        if (httpClient == null) {
            HttpParams parameters = new BasicHttpParams();
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
            httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(parameters, schemeRegistry), parameters);
        } 
        return httpClient;
    } 
 
    public static class Response { 
        private int statusCode;
        private InputStream responseBody;
 
        public Response(HttpResponse httpResponse) throws IOException {
            statusCode = httpResponse.getStatusLine().getStatusCode();
            responseBody = httpResponse.getEntity().getContent();
        } 
 
        public int getStatusCode() { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		SchemeRegistry schReg = new SchemeRegistry();
		schReg.register(new Scheme("http", PlainSocketFactory
				.getSocketFactory(), 80));
		schReg.register(new Scheme("https",
				SSLSocketFactory.getSocketFactory(), 443));
		ClientConnectionManager conMgr = new ThreadSafeClientConnManager(
				params, schReg);
 
		return new DefaultHttpClient(conMgr, params);
	} 
 
	public void clearCookies() { 
		httpClient.getCookieStore().clear();
	} 
 
	public void abort() { 
		try { 
			if (httpClient != null) {
				Log.i(TAG, "Abort.");
				httpPost.abort();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
 
        // Create the connection manager. 
        HTTP_CONNECTION_MANAGER = new ThreadSafeClientConnManager(params, schemeRegistry);
    } 
 
    public static final class Operation { 
        public String inOutEtag;
        public int outStatus;
        public InputStream outBody;
    } 
 
    public void setAuthToken(String authToken) {
        mAuthToken = authToken;
    } 
 
    public void get(String feedUrl, Operation operation) throws IOException {
        callMethod(new HttpGet(feedUrl), operation);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
				HttpParams params) {
			if (conman == null) {
				SchemeRegistry schemeRegistry = new SchemeRegistry();
				schemeRegistry.register(configureScheme());
 
				ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
				conman = cm;
			} 
 
			if (cleanupIdleConnections) {
				IdleConnectionMonitor.monitor(conman);
			} 
			return conman;
		} 
 
		private Scheme configureScheme() {
			if (enableSSL) {
                try { 
					AndroidSSLSocketFactory androidSSLSocketFactory = new AndroidSSLSocketFactory((KeyStore)null);
					androidSSLSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closeExpiredConnections, setDefaultMaxPerRoute, setMaxTotal
 
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
        schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
 
        clientConnManager = new ThreadSafeClientConnManager(schemeRegistry);
 
        clientConnManager.setMaxTotal(MAX_TOTAL_CONNECTIONS);
        clientConnManager.setDefaultMaxPerRoute(MAX_ROUTE_CONNECTIONS);
        clientConnManager.closeExpiredConnections();
 
        HttpConnectionParams.setConnectionTimeout(httpParams, CONNECT_TIMEOUT);
        HttpConnectionParams.setSoTimeout(httpParams, READ_TIMEOUT);
 
        System.setProperty("sun.net.client.defaultConnectTimeout", CONNECT_TIMEOUT+"");
        System.setProperty("sun.net.client.defaultReadTimeout", READ_TIMEOUT+"");
 
    } 
 
    public static HttpClient getHttpClient() {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
 
        schemeRegistry.register(
            new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
 
        mConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
        DefaultHttpClient httpClient = new DefaultHttpClient(mConnectionManager, params);
        httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
          @Override 
          public long getKeepAliveDuration(HttpResponse response,
                                           HttpContext context) {
            return 2 * 60 * 1000; // 2 minutes in millis 
          } 
        }); 
 
        httpClient.setReuseStrategy(new ConnectionReuseStrategy() {
          @Override 
          public boolean keepAlive(HttpResponse response, HttpContext context) {
            return true; 
          } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
        final SchemeRegistry reg = new SchemeRegistry();
        reg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        reg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
 
        final ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(config, reg);
 
        final DefaultHttpClient client = new DefaultHttpClient(manager, config);
        client.getParams().setParameter("http.socket.timeout", 30 * 1000);
        return client;
    } 
 
    @SuppressWarnings("deprecation") 
    public static String decodeSubscriptionURL(final String url) {
        if (url.startsWith("feed/")) {
            return "feed/" + URLDecoder.decode(url.substring(5));
        } else { 
            return url;
        } 
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		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;
	} 
	 
	/// create http request 
	static HttpUriRequest createHttpRequest(String url, int method) {
		Method m = Method.values()[method];
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android ThreadSafeClientConnManager Questions & Answers:

See Code Examples for Android ThreadSafeClientConnManager Methods: