public static InputStream getInputStreamWithHttpClient( String
resourceURL )
throws IOException
{
// Create an instance of HttpClient.
HttpClient client = new DefaultHttpClient();
// Create a method instance.
HttpGet method = new HttpGet( resourceURL );
method.getParams().setIntParameter(
CoreConnectionPNames.CONNECTION_TIMEOUT,
CONNECTION_TINEOUT );
method.getParams().setIntParameter
( CoreConnectionPNames.SO_TIMEOUT,
CONNECTION_TINEOUT );
method.getParams().setIntParameter(
CoreConnectionPNames.SOCKET_BUFFER_SIZE, IO_BUFFER_SIZE );
method.getParams().setIntParameter(
ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 );
method.getParams().setIntParameter(
ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 );
HttpResponse response = null;
InputStream input = null;
try
{
response = client.execute( method );
HttpEntity entity = response.getEntity();
input = entity.getContent();
}
catch ( IOException e )
{
Log.d( TAG, "Can not connect to the target server!" );
throw new IOException();
}
finally
{
Log.d( TAG, "close Expired Connections!" );
client.getConnectionManager().closeExpiredConnections();
}
return input;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---