Best code examples for Android DefaultHttpClient class (org.apache.http.impl.client.DefaultHttpClient)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DefaultHttpClient class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android DefaultHttpClient examples from Open Source projects
This code example shows how to use the following methods:
 
@Implements(AndroidHttpClient.class)
public class ShadowAndroidHttpClient { 
  @RealObject private AndroidHttpClient client;
 
  private HttpClient httpClient = new DefaultHttpClient();
 
  @Implementation 
  public static AndroidHttpClient newInstance(String userAgent) {
    return Robolectric.newInstanceOf(AndroidHttpClient.class);
  } 
 
  @Implementation 
  public static AndroidHttpClient newInstance(String userAgent, Context context) {
    return Robolectric.newInstanceOf(AndroidHttpClient.class);
  } 
 
  @Implementation 
  public HttpParams getParams() {
    return httpClient.getParams();
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: execute
	{ 
		if (uri.indexOf("http://") == -1)
			uri = "http://" + uri;
		boolean reached = isAvailable();
		try { 
			DefaultHttpClient httpclient = new DefaultHttpClient();
			HttpGet httpget = new HttpGet(uri);
			httpclient.execute(httpget);			
		} catch (Exception e) { 
			reached = false;
		} 
		return reached;
	} 
	 
	 
} 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
8
CodeRank
This code example shows how to use the following methods: getConnectionManager, setParams, setRoutePlanner, setRedirectStrategy
  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(
        getRoutePlanner(gridClient.getConnectionManager().getSchemeRegistry()));
    gridClient.getConnectionManager().closeIdleConnections(100, TimeUnit.MILLISECONDS);
 
    return gridClient;
  } 
 
  public HttpParams getHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setSoReuseaddr(params, true);
    HttpConnectionParams.setConnectionTimeout(params, 120 * 1000);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT_THREE_HOURS);
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: execute, getCredentialsProvider
 
    @Test 
    public void testSuccessfulAuthentication(@ArquillianResource URL webAppURL) throws Exception {
        DefaultHttpClient httpClient = createHttpClient(webAppURL, "User", "User");
 
        HttpResponse httpResponse = httpClient.execute(new HttpGet(webAppURL.toURI()));
 
        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
        httpResponse.getEntity().writeTo(bos);
 
        assertTrue(new String(bos.toByteArray()).contains("Welcome"));
    } 
 
    @Test 
    public void testUnsuccessfulAuthentication(@ArquillianResource URL webAppURL) throws Exception {
        DefaultHttpClient httpClient = createHttpClient(webAppURL, "Invalid User", "User");
 

8
CodeRank
Related Android DefaultHttpClient Questions & Answers:
Other Android DefaultHttpClient Examples
3:			try {
4:				// defaultHttpClient
5:				DefaultHttpClient httpClient = new DefaultHttpClient();
6:				HttpPost httpPost = new HttpPost(url);
7:	
-
3:			try {
4:				// defaultHttpClient
5:				DefaultHttpClient httpClient = new DefaultHttpClient();
6:				HttpPost httpPost = new HttpPost(url);
7:

Read More

43:					// request method is POST
44:					// defaultHttpClient
45:					DefaultHttpClient httpClient = new DefaultHttpClient();
46:					HttpPost httpPost = new HttpPost(url);
47:					httpPost.setEntity(new UrlEncodedFormEntity(params));
-
43:					// request method is POST
44:					// defaultHttpClient
45:					DefaultHttpClient httpClient = new DefaultHttpClient();
46:					HttpPost httpPost = new HttpPost(url);
47:					httpPost.setEntity(new UrlEncodedFormEntity(params));
-
53:				} else if (method == "GET") {
54:					// request method is GET
55:					DefaultHttpClient httpClient = new DefaultHttpClient();
56:					String paramString = URLEncodedUtils.format(params, "utf-8");
57:					url += "?" + paramString;
-
53:				} else if (method == "GET") {
54:					// request method is GET
55:					DefaultHttpClient httpClient = new DefaultHttpClient();
56:					String paramString = URLEncodedUtils.format(params, "utf-8");
57:					url += "?" + paramString;

Read More

44:					// defaultHttpClient
45:					DefaultHttpClient httpClient = new DefaultHttpClient();
46:					HttpPost httpPost = new HttpPost(url);
47:					httpPost.setEntity(new UrlEncodedFormEntity(params));
48:	
-
44:					// defaultHttpClient
45:					DefaultHttpClient httpClient = new DefaultHttpClient();
46:					HttpPost httpPost = new HttpPost(url);
47:					httpPost.setEntity(new UrlEncodedFormEntity(params));
48:	
-
54:					// request method is GET
55:					DefaultHttpClient httpClient = new DefaultHttpClient();
56:					String paramString = URLEncodedUtils.format(params, "utf-8");
57:					url += "?" + paramString;
58:					HttpGet httpGet = new HttpGet(url);
-
54:					// request method is GET
55:					DefaultHttpClient httpClient = new DefaultHttpClient();
56:					String paramString = URLEncodedUtils.format(params, "utf-8");
57:					url += "?" + paramString;
58:					HttpGet httpGet = new HttpGet(url);

Read More

See Code Examples for Android DefaultHttpClient Methods: