Code example for ThreadSafeClientConnManager

0
    schemeRegistry.register(new Scheme("http",
        PlainSocketFactory.getSocketFactory(), 80));
    schemeRegistry.register(new Scheme("https",
        SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager manager =
        new ThreadSafeClientConnManager(params, schemeRegistry);
 
    // We use a factory method to modify superclass initialization 
    // parameters without the funny call-a-static-method dance. 
    return new AndroidHttpClient(manager, params);
  } 
 
  private final HttpClient delegate;
 
 
  private AndroidHttpClient(ClientConnectionManager ccm, HttpParams params) {
    this.delegate = new DefaultHttpClient(ccm, params) {
      @Override 
      protected BasicHttpProcessor createHttpProcessor() {
        // Add interceptor to prevent making requests from main thread. 
        BasicHttpProcessor processor = super.createHttpProcessor();