本文整理汇总了Java中com.android.volley.toolbox.HttpClientStack类的典型用法代码示例。如果您正苦于以下问题:Java HttpClientStack类的具体用法?Java HttpClientStack怎么用?Java HttpClientStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpClientStack类属于com.android.volley.toolbox包,在下文中一共展示了HttpClientStack类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newRequestQueue
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
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;
}
示例2: getRequestQueue
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
@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;
}
示例3: OdooWrapper
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
public OdooWrapper(Context context, String baseURL) {
serverURL = stripURL(baseURL);
gson = new Gson();
responseQueue = new OdooResponseQueue();
requestQueue = Volley.newRequestQueue(context,
new HttpClientStack(OdooSafeClient.getSafeClient(true)));
}
示例4: newRequestQueue
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
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;
}
示例5: getRequestQueue
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
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;
}
示例6: createStack
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
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();
}
}
示例7: onCreate
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
@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();
}
示例8: onCreate
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sRequestQueue = Volley.newRequestQueue(
getApplicationContext(),
new HttpClientStack(AndroidHttpClient
.newInstance("com.imbryk.demo/0")));
sImageLoader = new ImageLoader(sRequestQueue, new BitmapLruCache());
}
示例9: createHttpStack
import com.android.volley.toolbox.HttpClientStack; //导入依赖的package包/类
@Override
public HttpStack createHttpStack(@NonNull final Context context) {
return new HttpClientStack(createHttpClient(context));
}