private static RequestQueue newRequestQueue(Context context) { // On HC+ use HurlStack which is based on HttpURLConnection. Otherwise fall back on // AndroidHttpClient (based on Apache DefaultHttpClient) which should no longer be used // on newer platform versions where HttpURLConnection is simply better. Network network = new BasicNetwork( UIUtils.hasHoneycomb() ? new HurlStack() : new HttpClientStack(AndroidHttpClient.newInstance( NetUtils.getUserAgent(context)))); Cache cache = new DiskBasedCache(getDiskCacheDir(context, CACHE_DIR)); RequestQueue queue = new RequestQueue(cache, network); queue.start(); return queue; }
public OdooWrapper(Context context, String baseURL) { serverURL = stripURL(baseURL); gson = new Gson(); responseQueue = new OdooResponseQueue(); requestQueue = Volley.newRequestQueue(context, new HttpClientStack(OdooSafeClient.getSafeClient(true))); }
private static RequestQueue newRequestQueue(Context context) { // On HC+ use HurlStack which is based on HttpURLConnection. Otherwise fall back on // AndroidHttpClient (based on Apache DefaultHttpClient) which should no longer be used // on newer platform versions where HttpURLConnection is simply better. Network network = new BasicNetwork(Utils.hasHoneycomb() ? new HurlStack() : new HttpClientStack(AndroidHttpClient.newInstance(Utils.getUserAgent(context)))); Cache cache = new DiskBasedCache(getDiskCacheDir(context, CACHE_DIR), DEFAULT_DISK_USAGE_BYTES); RequestQueue queue = new RequestQueue(cache, network); queue.start(); return queue; }
public RequestQueue getRequestQueue() { // if (mRequestQueue == null) { // mRequestQueue = Volley.newRequestQueue(getApplicationContext()); // } // // return mRequestQueue; if (mRequestQueue == null) { httpClient = HttpClients.custom() .setConnectionManager(new PoolingHttpClientConnectionManager()) .setDefaultCookieStore(new PersistentCookieStore(getApplicationContext())) .build(); mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new HttpClientStack(httpClient)); } return mRequestQueue; }
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private static RequestQueue getRequestQueue() { if (mRequestQueue == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.setRedirectHandler(new DefaultRedirectHandler() { @Override public boolean isRedirectRequested(HttpResponse response, HttpContext context) { boolean isRedirect = super.isRedirectRequested( response, context); if (!isRedirect) { int responseCode = response.getStatusLine() .getStatusCode(); if (responseCode == 301 || responseCode == 302) { return true; } } return isRedirect; } }); httpClient.setCookieStore(new BasicCookieStore()); HttpStack httpStack = new HttpClientStack(httpClient); mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance() .getApplicationContext(), httpStack); } else { HttpURLConnection.setFollowRedirects(true); CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance() .getApplicationContext()); } } return mRequestQueue; }
public static HttpStack createStack() { if(hasOkHttp()) { OkHttpClient okHttpClient = new OkHttpClient(); VolleyLog.d("OkHttp found, using okhttp for http stack"); return new OkHttpStack(okHttpClient); } else if (useHttpClient()){ VolleyLog.d("Android version is older than Gingerbread (API 9), using HttpClient"); return new HttpClientStack(AndroidHttpClient.newInstance(USER_AGENT)); } else { VolleyLog.d("Using Default HttpUrlConnection"); return new HurlStack(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_import_gutenberg_top_100); getSupportActionBar().setDisplayHomeAsUpEnabled(true); client = new DefaultHttpClient(); queue = Volley.newRequestQueue(this, new HttpClientStack(client)); loadTop100List(); }
@Override public void onCreate() { super.onCreate(); sRequestQueue = Volley.newRequestQueue( getApplicationContext(), new HttpClientStack(AndroidHttpClient .newInstance("com.imbryk.demo/0"))); sImageLoader = new ImageLoader(sRequestQueue, new BitmapLruCache()); }
@Override public HttpStack createHttpStack(@NonNull final Context context) { return new HttpClientStack(createHttpClient(context)); }