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

This code example shows how to use the following methods:register
		} 
 
		public ClientConnectionManager configureConnectionManager(
				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) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:get, getScheme, register, unregister,
        Assert.assertNotNull(schmreg.get(name));
    } 
 
    @Test 
    public void testIllegalRegisterUnregister() { 
        SchemeRegistry schmreg = new SchemeRegistry();
        try { 
            schmreg.register(null);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected 
        } 
        try { 
            schmreg.unregister(null);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected 
        } 
        try { 
            schmreg.get(null);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        ConnManagerParams.setTimeout(params, 10000);
 
        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(18); // Giving 18 connections to Evernote
        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
 
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(
            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 
          } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:register
		params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
 
		//ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); 
	         
	    SchemeRegistry registry = new SchemeRegistry();
	    registry.register(new Scheme("http", new PlainSocketFactory(), 80)); 
	    registry.register(new Scheme("https", (trustAll  ? EasySSLSocketFactory.getSocketFactory(): SSLSocketFactory.getSocketFactory()), 443));
	    DefaultHttpClient client = new DefaultHttpClient(new ThreadSafeClientConnManager(params, registry), params);
		 
	       return client;
	} 
	 
	public CaldavFacade(String mUser, String mPassword, String mURL) throws MalformedURLException  {
		url = new URL(mURL);
		 
		httpClient = getHttpClient();
		 
	    UsernamePasswordCredentials upc = new UsernamePasswordCredentials(mUser, mPassword);
		 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        ConnManagerParams.setTimeout(params, 10000);
         
        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(18); // Giving 18 connections to Evernote
        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
         
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(
                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 
          } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:register
 
	        HttpParams params = new BasicHttpParams();
	        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
	        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
 
	        SchemeRegistry registry = new SchemeRegistry();
	        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
	        registry.register(new Scheme("https", sf, 443));
 
	        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
 
	        return new DefaultHttpClient(ccm, params);
	    }  
	     
	    catch (Exception e) {
	        return new DefaultHttpClient();
	    } 
	} 
	 
    @Override 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setItems
    public static URIFetcher createSafeHttpClientURIFetcher(final Closure<HttpParams> paramsClosure,
            final Closure<DefaultHttpClient> httpClientClosure) {
        final Map<String, Scheme> registries = new HashMap<String, Scheme>();
        registries.put("http", new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registries.put("https", new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        final SchemeRegistry schemaRegistry = new SchemeRegistry();
        schemaRegistry.setItems(registries);
         
        final HttpParams params = createHttpParams();
        if(paramsClosure != null) {
            paramsClosure.execute(params);
        } 
        final ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemaRegistry);
        final DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);
        if(httpClientClosure != null) {
            httpClientClosure.execute(httpclient);
        } 
        final CharsetStrategy charsetStrategy = new ChainedCharsetStrategy(asList(
                new DefaultHttpCharsetStrategy(), new FixedCharsetStrategy("utf-8"))); 
         
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:register
public class Fetcher { 
	DefaultHttpClient httpclient;
	String baseURL;
 
	public Fetcher(String baseURL) {
	    SchemeRegistry registry = new SchemeRegistry();
	    registry.register(new Scheme("http", new PlainSocketFactory(), 80));
	    registry.register(new Scheme("https", new FakeSocketFactory(), 443));
        HttpParams httpparams = new BasicHttpParams();
	    httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpparams, registry), httpparams);
 
	    if (!baseURL.endsWith("/")) baseURL += "/";
	    this.baseURL = baseURL;
	} 
 
	public String doLogin(String username, String password) {
	    HttpPost httpost = new HttpPost(baseURL + "login");
 
	    try { 
		    httpost.setEntity(new StringEntity("{\"user\":{\"login\":\"" + username + "\",\"password\":\"" + password + "\"}}"));
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:register
            HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
            HttpConnectionParams 
                    .setConnectionTimeout(params, connectionTimeout);
            HttpConnectionParams.setSoTimeout(params, socketTimeout);
 
            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", PlainSocketFactory
                    .getSocketFactory(), 80));
            registry.register(new Scheme("https", sf, 443));
 
            ClientConnectionManager ccm = new ThreadSafeClientConnManager(
                    params, registry);
 
            return new DefaultHttpClient(ccm, params);
        } catch (Exception e) {
            return new DefaultHttpClient();
        } 
    } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:register
							params,
							"Mozilla/5.0 (Linux; U; Android 2.1; en-us; ADR6200 Build/ERD79) AppleWebKit/530.17 (KHTML, like Gecko) Version/ 4.0 Mobile Safari/530.17"); 
			ConnManagerParams.setTimeout(params, 1000);
			HttpConnectionParams.setConnectionTimeout(params, 5000);
			HttpConnectionParams.setSoTimeout(params, 10000);
			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);
			customHttpClient = new DefaultHttpClient(conMgr, params);
		} 
		return customHttpClient;
	} 
 
	public static String getString(final String uri) {
 
		HttpGet httpGet = new HttpGet(uri);
		HttpResponse httpResponse = executeRequest(httpGet);
		return getHttpResonseAsString(httpResponse);
	} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android SchemeRegistry Questions & Answers:

See Code Examples for Android SchemeRegistry Methods: