Back to project page Volley-Ball.
The source code is released under:
MIT License
If you think the Android project Volley-Ball 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.siu.android.volleyball.util; /* www.jav a2 s .c o m*/ import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.http.AndroidHttpClient; import android.os.Build; import com.android.volley.Network; import com.android.volley.toolbox.BasicNetwork; import com.android.volley.toolbox.HttpClientStack; import com.android.volley.toolbox.HttpStack; import com.android.volley.toolbox.HurlStack; /** * Created by lukas on 8/31/13. */ public class ConfigUtils { public static final HttpStack getDefaultHttpStack(Context context) { String userAgent = "volley/0"; try { String packageName = context.getPackageName(); PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); userAgent = packageName + "/" + info.versionCode; } catch (PackageManager.NameNotFoundException e) { } HttpStack stack; if (Build.VERSION.SDK_INT >= 9) { stack = new HurlStack(); } else { // Prior to Gingerbread, HttpUrlConnection was unreliable. // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent)); } return stack; } public static Network getDefaultNetwork(HttpStack httpStack) { return new BasicNetwork(httpStack); } public static Network getDefaultNetworkWithDefaultHttpStack(Context context) { return new BasicNetwork(getDefaultHttpStack(context)); } }