Code example for UsernamePasswordCredentials

0
	ReusableHttpClientBlocking(int timeout, String user, String password) {
		Log.d(TAG, "Creating a new HTTP client");
		mHttpClient = new DefaultHttpClient();
		if (!TextUtils.isEmpty(password)) {
			CredentialsProvider credProvider = new BasicCredentialsProvider();
		    credProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), 
		    		new UsernamePasswordCredentials(user, password));
		    mHttpClient.setCredentialsProvider(credProvider);
		} 
		mRequest = new HttpGet();
		mRequest.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(timeout));
		mRequest.getParams().setParameter(CoreConnectionPNames.SO_LINGER, new Integer(timeout/2));
		mRequest.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(timeout));
	} 
 
	/** 
	 * Perform the blocking fetch. 
	 * @throws IOException  
	 * @throws URISyntaxException  
	 */ 
	public synchronized Response fetch(String url) throws IOException, URISyntaxException {