Skip to content

Instantly share code, notes, and snippets.

Created July 25, 2012 01:06
Show Gist options
  • Save anonymous/3173748 to your computer and use it in GitHub Desktop.
Save anonymous/3173748 to your computer and use it in GitHub Desktop.
Example of a thread safe HttpClient in Android.
public static DefaultHttpClient getThreadSafeClient() {
DefaultHttpClient client = new DefaultHttpClient();
ClientConnectionManager mgr = client.getConnectionManager();
HttpParams params = client.getParams();
client = new DefaultHttpClient(
new ThreadSafeClientConnManager(params,
mgr.getSchemeRegistry()), params);
return client;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment