Code example for AbstractHttpClient

Methods: getParamssetHttpRequestRetryHandler

0
		HttpParams clientParams = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(clientParams, 10 * 1000);
		HttpConnectionParams.setSoTimeout(clientParams, 10 * 1000);
		ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(clientParams, schemeRegistry);	
		httpClient = new DefaultHttpClient(cm, null);
		httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Jaker App 1.0");
		retryHandler = new DefaultHttpRequestRetryHandler(5, false) {
			@Override 
			public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
				Log.i("http-exception", exception.getClass().getSimpleName() + " : " + exception.getMessage());
				 
				boolean result = super.retryRequest(exception, executionCount, context);
				 
				if (result == false) return false;
				 
				if (exception instanceof NoHttpResponseException) return true;
				 
				try { Thread.sleep(2000); } catch (InterruptedException e) { }
				 
				return true; 
			} 
		}; 
		httpClient.setHttpRequestRetryHandler(retryHandler);
	} 
	 
	public static AbstractHttpClient getHTTPClient() {
		return httpClient;
	} 
Connect your IDE to all the code out there  Get Codota for Java