Back to project page tapad-android-sdk.
The source code is released under:
MIT License
If you think the Android project tapad-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.tapad.util; /* ww w. j a va2s . co m*/ import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; import org.apache.http.params.HttpProtocolParams; import org.apache.http.protocol.HttpContext; /** * Utility class for setting sensible defaults on Http Clients used in the * Tapad SDK. */ public class HttpClientUtil { public static DefaultHttpClient createClient(String userAgent) { // Event occur infrequently, so we use a vanilla single-threaded // client. HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUserAgent(params, userAgent); DefaultHttpClient client = new DefaultHttpClient(params); // Keep connections alive for 5 seconds. client.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) { return 5000; } }); return client; } }