Android ClientConnectionManager - 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 ClientConnectionManager class.

This code example shows how to use the following methods:closeExpiredConnections, closeIdleConnections
 
  private DefaultHttpClient getHTTPClient() {
 
    try { 
      if (mConnectionManager != null) {
        mConnectionManager.closeExpiredConnections();
        mConnectionManager.closeIdleConnections(1, TimeUnit.SECONDS);
      } else { 
        BasicHttpParams params = new BasicHttpParams();
 
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 20000);
 
        ConnManagerParams.setMaxTotalConnections(params, ConnManagerParams.DEFAULT_MAX_TOTAL_CONNECTIONS);
        ConnManagerParams.setTimeout(params, 10000);
 
        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(18); // Giving 18 connections to Evernote
        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
 
        SchemeRegistry schemeRegistry = new SchemeRegistry();
6
CodeRank
This code example shows how to use the following methods:closeExpiredConnections, closeIdleConnections
   
  private DefaultHttpClient getHTTPClient() {
     
    try{ 
      if(mConnectionManager != null){
        mConnectionManager.closeExpiredConnections();
        mConnectionManager.closeIdleConnections(1, TimeUnit.SECONDS);
      }else{ 
        BasicHttpParams params = new BasicHttpParams();
         
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 20000);
         
        ConnManagerParams.setMaxTotalConnections(params, ConnManagerParams.DEFAULT_MAX_TOTAL_CONNECTIONS);
        ConnManagerParams.setTimeout(params, 10000);
         
        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(18); // Giving 18 connections to Evernote
        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
         
        SchemeRegistry schemeRegistry = new SchemeRegistry();
6
CodeRank
This code example shows how to use the following methods:shutdown
            AndroidHttpClient client = (AndroidHttpClient) instance;
            client.close();
        } else { 
            ClientConnectionManager mgr = instance.getConnectionManager();
            if (mgr != null)
                mgr.shutdown();
        } 
    } 
 
    public static void setUserAgentString(String userAgent) {
    	sUserAgent = userAgent;
    } 
     
    public static String getUserAgentString() {
        return sUserAgent;
    } 
} 
 
5
CodeRank
This code example shows how to use the following methods:shutdown
	// } 
 
	public void shutDown() { 
		mShutDown = true;
		if (mCcm != null) {
			mCcm.shutdown();
		} 
 
		// if (clientSocket != null) { 
		// try { 
		// clientSocket.close(); 
		// } catch (IOException e) { 
		// e.printStackTrace(); 
		// } 
		// clientSocket = null; 
		// } 
	} 
} 
3
CodeRank
This code example shows how to use the following methods:shutdown
	 
	/** 
	 * stop feed parse and disconnect http connection. 
	 */ 
	public void stop() { 
		connManager.shutdown();
	} 
	 
	/** 
	 * get rss feed object. 
	 */ 
	public RSSFeed getFeed() { 
		return handler.getFeed();
	} 
	 
	 
	private class ParserListener implements IParserListener { 
 
		private long lastItemTimestamp;
		 
4
CodeRank
This code example shows how to use the following methods:shutdown
      schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
      final ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
      closer.addToClose(new Closeable() {
         @Override 
         public void close() throws IOException { 
            cm.shutdown();
         } 
      }); 
      return cm;
   } 
 
   @Provides 
   @Singleton 
   HttpClient newDefaultHttpClient(HttpUtils utils, BasicHttpParams params,
            ClientConnectionManager cm) {
      DefaultHttpClient client = new DefaultHttpClient(cm, params);
      if (utils.useSystemProxies()) {
         ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(client
                  .getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault());
         client.setRoutePlanner(routePlanner);
4
CodeRank
This code example shows how to use the following methods:shutdown
            AndroidHttpClient client = (AndroidHttpClient) instance;
            client.close();
        } else { 
            ClientConnectionManager mgr = instance.getConnectionManager();
            if (mgr != null)
                mgr.shutdown();
        } 
    } 
 
    public static void setUserAgentString(String userAgent) {
    	sUserAgent = userAgent;
    } 
     
    public static String getUserAgentString() {
        return sUserAgent;
    } 
} 
 
4
CodeRank
This code example shows how to use the following methods:shutdown
     
    public void shutdown() { 
        if (client != null) {
            ClientConnectionManager connectionManager = client.getConnectionManager();
            if (connectionManager != null) {
                connectionManager.shutdown();
            } 
        } 
    } 
 
    public <T extends OAuthClientResponse> T execute(OAuthClientRequest request,
                                                     Map<String, String> headers,
                                                     String requestMethod,
                                                     Class<T> responseClass)
        throws OAuthSystemException, OAuthProblemException { 
 
        try { 
            URI location = new URI(request.getLocationUri());
            HttpRequestBase req = null;
            String responseBody = "";
4
CodeRank
This code example shows how to use the following methods:shutdown
  @Override 
  protected void tearDown() throws Exception { 
    if (mClient != null) {
      ClientConnectionManager connectionManager = mClient.getConnectionManager();
      if (connectionManager != null) {
        connectionManager.shutdown();
      } 
    } 
    super.tearDown(); 
  } 
 
  public void testClientClass() throws Exception { 
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1) {
      assertEquals(
          getContext().getClassLoader().loadClass(DefaultHttpClient.class.getName()),
          mClient.getClass());
    } else { 
      assertEquals(
          getContext().getClassLoader().loadClass("android.net.http.AndroidHttpClient"),
          mClient.getClass());
4
CodeRank
This code example shows how to use the following methods:shutdown
	    // shut down the connection manager to ensure 
	    // immediate deallocation of all system resources 
		if(httpclient!=null) {
			ClientConnectionManager connectionManager = httpclient.getConnectionManager();
			if(connectionManager!=null) {
				connectionManager.shutdown();
			} 
		} 
		 
		super.onDestroy(); 
	} 
	 
	public String getCurrentTimeAsString() {
		time.setToNow();
		return time.format3339(false);
		///To change this str back into a Time object, use the following: 
		//    Time readTime = new Time(); 
		//    readTime.parse3339(timeStr);  //str was saved out using RFC3339 format, so needs to be read in as such 
		//    readTime.switchTimezone("Asia/Tokyo");  //parse3339() automatically converts read in times to UTC.  We need to change it back to the default timezone of the handset (JST in this example) 
	} 
4
CodeRank

Related Android ClientConnectionManager Questions & Answers:

See Code Examples for Android ClientConnectionManager Methods: