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

This code example shows how to use the following methods:
     * Sets the SSLSocketFactory to user when making requests. By default, 
     * a new, default SSLSocketFactory is used. 
     * @param sslSocketFactory the socket factory to use for https requests. 
     */ 
    public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
        this.httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", sslSocketFactory, 443));
    } 
     
    /** 
     * Sets headers that will be added to all requests this client makes (before sending). 
     * @param header the name of the header 
     * @param value the contents of the header 
     */ 
    public void addHeader(String header, String value) {
        clientHeaderMap.put(header, value);
    } 
 
    /** 
     * Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as 
     * setBasicAuth('username','password',AuthScope.ANY)  
7
CodeRank
This code example shows how to use the following methods:
                } catch (Exception ignored) {
                } 
            } 
        }; 
        client.getConnectionManager().getSchemeRegistry()
                .register(new Scheme("https", socketFactory, 443));
    } 
     
    public static void setApplicationContext(Context applicationContext) {
        if (mApplicationContext == null) {
            mApplicationContext = applicationContext;
            try { 
                sUserAgent += "/"
                        + applicationContext.getPackageManager().getPackageInfo(
                                applicationContext.getPackageName(), 0).versionCode;
            } catch (NameNotFoundException ignored) {
                // this isn't much important, just ignore if the version could 
                // not be retrieved. 
            } 
        } 
6
CodeRank
This code example shows how to use the following methods:
        // Create a registry for our three schemes; http and https will use built-in factories 
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http",
                PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https",
                SSLUtils.getHttpSocketFactory(false, keyManager), 443));
 
        // Register the httpts scheme with our insecure factory 
        registry.register(new Scheme("httpts",
                SSLUtils.getHttpSocketFactory(true /*insecure*/, keyManager), 443));
 
        return new EmailClientConnectionManager(params, registry, keyManager);
    } 
 
    /** 
     * Ensures that a client SSL certificate is known to be used for the specified connection 
     * manager. 
     * A {@link SchemeRegistry} is used to denote which client certificates to use for a given 
     * connection, so clients of this connection manager should use 
     * {@link #makeSchemeForClientCert(String, boolean)}. 
6
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
		private Scheme configureScheme() {
			if (enableSSL) {
                try { 
					AndroidSSLSocketFactory androidSSLSocketFactory = new AndroidSSLSocketFactory((KeyStore)null);
					androidSSLSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
					return new Scheme("https", androidSSLSocketFactory, port);
				} catch (Exception e) {
					throw Exceptions.propagate(e);
				} 
			} else { 
				return new Scheme("http", PlainSocketFactory.getSocketFactory(), port);
			} 
		} 
 
		public org.apache.http.client.HttpClient configureClient() {
			HttpParams params = new BasicHttpParams();
			HttpProtocolParams.setUseExpectContinue(params, useExpectContinue);
			HttpConnectionParams 
					.setConnectionTimeout(params, connectionTimeout);
			HttpConnectionParams.setSoTimeout(params, socketTimeout);
5
CodeRank
This code example shows how to use the following methods:
     * Sets the SSLSocketFactory to user when making requests. By default, 
     * a new, default SSLSocketFactory is used. 
     * @param sslSocketFactory the socket factory to use for https requests. 
     */ 
    public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
        this.httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", sslSocketFactory, 443));
    } 
     
    /** 
     * Sets headers that will be added to all requests this client makes (before sending). 
     * @param header the name of the header 
     * @param value the contents of the header 
     */ 
    public void addHeader(String header, String value) {
        clientHeaderMap.put(header, value);
    } 
 
    /** 
     * Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as 
     * setBasicAuth('username','password',AuthScope.ANY)  
6
CodeRank
This code example shows how to use the following methods:
		 
		// 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();
5
CodeRank
This code example shows how to use the following methods:
 
    private void registerTrustAllScheme(int port)
            throws KeyManagementException, NoSuchAlgorithmException, 
            KeyStoreException, UnrecoverableKeyException { 
        TrustAllSSLSocketFactory tasslf = new TrustAllSSLSocketFactory();
        Scheme sch = new Scheme("https", tasslf, port);
        getConnectionManager().getSchemeRegistry().register(sch);
    } 
 
    private void setCredentials(Credentials cred) {
        BasicCredentialsProvider cP = new BasicCredentialsProvider();
        cP.setCredentials(AuthScope.ANY, cred);
        setCredentialsProvider(cP);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    /** create a safe {@link URIFetcher} */ 
    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
This code example shows how to use the following methods:
				.getSocketFactory(), 80));
		 
		// TODO: Warn: we are trusting all certificates 
		//registry.register(new Scheme("https", (trustAll ? new FakeSocketFactory() : SSLSocketFactory.getSocketFactory()), 443)); 
		try { 
			schReg.register(new Scheme("https", new TrustAllSSLSocketFactory(), 443));
		} catch (Exception e) {
			schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
			 
		} 
		ClientConnectionManager conMgr = new ThreadSafeClientConnManager(
				params, schReg);
 
		sClient = new DefaultHttpClient(conMgr, params);
	} 
 
	private HttpManager() { 
	} 
 
	public static HttpResponse execute(HttpHead head) throws IOException {
5
CodeRank

Related Android Scheme Questions & Answers:

See Code Examples for Android Scheme Methods: