public class XUtilsHelper {
private static HttpUtils client;
public static PreferencesCookieStore cookieStore;
/**
* 单例模式获取实例对象
*
* @param context
* 应用程序上下文
* @return HttpUtils对象实例
*/
public static HttpUtils getInstence(Context context) {
if (client == null) {
// 设置请求超时时间为20秒
client = new HttpUtils(2000 * 10);
client.configSoTimeout(2000 * 10);
client.configResponseTextCharset("UTF-8");
cookieStore = new PreferencesCookieStore(context);
// LogUtils.e("cookie--->"+cookieStore.getCookies().toString());
// cookieStore.clear(); // 清除原来的cookie
client.configCookieStore(cookieStore);
}
return client;
}
}